// Use this for initialization public override void Start() { base.Start(); motor = GetComponent<CharacterMotor>(); animator = GetComponentInChildren<Animator>(); StartCoroutine("AI"); }
// bool inReload { get { return animation[reloadAnimation.name].enabled; } } // bool inTransition { get { return animation[gunOffAnimation.name].enabled || animation[gunOnAnimation.name].enabled; } } // bool inFire { get { return animation[fireAnimation.name].enabled; } } // Set up upper body animation /*private void SetupGunAnimation (AnimationClip animationClip) { AnimationState a = animation[animationClip.name]; a.wrapMode = WrapMode.Once; a.layer = 1; a.AddMixingTransform(spine); a.AddMixingTransform(rightGun); }*/ // Use this for initialization void Start () { // if (gunOnAnimation == null || gunOffAnimation == null || reloadAnimation == null || fireAnimation == null || muzzleFlash == null) enabled = false; /* SetupGunAnimation(gunOnAnimation); SetupGunAnimation(gunOffAnimation); SetupGunAnimation(reloadAnimation);*/ // setup additive fire animation /*AnimationState fireAS = animation[fireAnimation.name]; fireAS.wrapMode = WrapMode.Once; fireAS.layer = 101; // we put it in a separate layer than impact animations fireAS.blendMode = AnimationBlendMode.Additive;*/ motor = GetComponent(typeof(CharacterMotor)) as CharacterMotor; LegController legC = GetComponent(typeof(LegController)) as LegController; IMotionAnalyzer[] motions = legC.motions; foreach (IMotionAnalyzer motion in motions) { if (motion.name == "RunForward") maxSpeedWithGun = motion.cycleSpeed; if (motion.name == "RunForwardNoGun") maxSpeedWithoutGun = motion.cycleSpeed; //if (motion.name == "RunForwardFastNoGun") // maxSpeedWithoutGun = motion.cycleSpeed; } muzzleFlash.enabled = false; }
// Use this for initialization void Start() { chMotor = GetComponent<CharacterMotor>(); tr = transform; CharacterController ch = GetComponent<CharacterController>(); dist = ch.height/2; // calculate distance to ground }
// Use this for initialization void Start() { controller = gameObject.transform.root.GetComponent<CharacterController>(); motor = gameObject.transform.root.GetComponent<CharacterMotor>(); inventory = gameObject.transform.root.GetComponent<Inventory>(); vitals = gameObject.transform.root.GetComponent<PlayerVitals>(); }
//setup void Awake() { //create single floorcheck in centre of object, if none are assigned if(!floorChecks) { floorChecks = new GameObject().transform; floorChecks.name = "FloorChecks"; floorChecks.parent = transform; floorChecks.position = transform.position; GameObject check = new GameObject(); check.name = "Check1"; check.transform.parent = floorChecks; check.transform.position = transform.position; Debug.LogWarning("No 'floorChecks' assigned to PlayerMove script, so a single floorcheck has been created", floorChecks); } //assign player tag if not already if(tag != "Player") { tag = "Player"; Debug.LogWarning ("PlayerMove script assigned to object without the tag 'Player', tag has been assigned automatically", transform); } //usual setup mainCam = GameObject.FindGameObjectWithTag("MainCamera").transform; dealDamage = GetComponent<DealDamage>(); characterMotor = GetComponent<CharacterMotor>(); rigid = GetComponent<Rigidbody>(); aSource = GetComponent<AudioSource>(); //gets child objects of floorcheckers, and puts them in an array //later these are used to raycast downward and see if we are on the ground floorCheckers = new Transform[floorChecks.childCount]; for (int i=0; i < floorCheckers.Length; i++) floorCheckers[i] = floorChecks.GetChild(i); }
void Awake() { movement = pc.GetComponent <CharacterMotor> (); message = text.GetComponent <uiSystem> (); cam = holder.GetComponent <cameraScript> (); menu = holder.GetComponent <menuScript> (); }
//Variables End___________________________________________________________ // Use this for initialization void Start() { if(networkView.isMine == true) { myTransform = transform; cameraHead = myTransform.FindChild("CameraHead"); motorScript = myTransform.GetComponent<CharacterMotor>(); //Access the PlayerStats script and get the player's max speed. //This is their normal movement speed outside of the water. GameObject gManager = GameObject.Find("GameManager"); PlayerStats statScript = gManager.GetComponent<PlayerStats>(); normalSpeed = statScript.maxSpeed; } else { enabled = false; } }
//setup void Awake() { characterMotor = GetComponent<CharacterMotor>(); dealDamage = GetComponent<DealDamage>(); //avoid setup errors if(tag != "Enemy") { tag = "Enemy"; Debug.LogWarning("'EnemyAI' script attached to object without 'Enemy' tag, it has been assign automatically", transform); } if(sightBounds) { sightTrigger = sightBounds.GetComponent<TriggerParent>(); if(!sightTrigger) Debug.LogError("'TriggerParent' script needs attaching to enemy 'SightBounds'", sightBounds); } if(!sightBounds) Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'SightBounds' or enemy will not be able to see", transform); if(attackBounds) { attackTrigger = attackBounds.GetComponent<TriggerParent>(); if(!attackTrigger) Debug.LogError("'TriggerParent' script needs attaching to enemy 'attackBounds'", attackBounds); } else Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'AttackBounds' or enemy will not be able to attack", transform); }
// Use this for initialization void Awake() { _Game = GameObject.Find("Game"); c_Game = _Game.GetComponentInChildren<Game>(); motor = GetComponent<CharacterMotor>(); }
// Use this for initialization void Start() { Input.multiTouchEnabled = true; characterMotorScript = objPlayer.GetComponent<CharacterMotor>(); characterJumpScript = objPlayer.GetComponent<CharacterJump2>(); characterShotScript = objPlayer.GetComponent<CharacterShot>(); }
//setup void Awake() { if(transform.tag != "Enemy") { //add kinematic rigidbody if(!GetComponent<Rigidbody>()) gameObject.AddComponent<Rigidbody>(); GetComponent<Rigidbody>().isKinematic = true; GetComponent<Rigidbody>().useGravity = false; GetComponent<Rigidbody>().interpolation = RigidbodyInterpolation.Interpolate; } else { characterMotor = GetComponent<CharacterMotor>(); enemyAI = GetComponent<EnemyAI>(); } //get child waypoints, then detach them (so object can move without moving waypoints) foreach (Transform child in transform) if(child.tag == "Waypoint") waypoints.Add (child); foreach(Transform waypoint in waypoints) waypoint.parent = null; if(waypoints.Count == 0) Debug.LogError("No waypoints found for 'MoveToPoints' script. To add waypoints: add child gameObjects with the tag 'Waypoint'", transform); }
// Use this for initialization void Start () { audioSource.clip = audio; mouse = player.GetComponent<MouseLook>(); motor = player.GetComponent<CharacterMotor>(); triggered = false; charControl = player.GetComponent<CharacterController>(); }
void Start() { worldManager = (WorldManager)FindObjectOfType (typeof(WorldManager)); guiManager = (GUIManager)FindObjectOfType (typeof(GUIManager)); characterMotor=worldManager.getPlayer().GetComponent<CharacterMotor>(); }
void Awake() { cameraScript = GetComponent<MouseLook>(); cameraScript2 = camera.GetComponent<MouseLook>(); controllerScript = GetComponent<CharacterMotor>(); shotScript = GetComponent<Shot>(); if (photonView.isMine) { this.camera.camera.enabled=true; cameraScript.enabled = true; cameraScript2.enabled = true; controllerScript.canControl = true; shotScript.enabled=true; } else { this.camera.camera.enabled=false; cameraScript.enabled = false; cameraScript2.enabled = false; controllerScript.canControl = false; shotScript.enabled=false; } gameObject.name = gameObject.name + photonView.viewID.ID; }
// Use this for initialization private void OnEnable() { myTransform = transform; characterMotor = GetComponent<CharacterMotor>(); characterController = GetComponent<CharacterController>(); isFlying = false; }
// Use this for initialization void Start() { motor = GetComponent(typeof(CharacterMotor)) as CharacterMotor; if (motor==null) Debug.Log("Motor is null!!"); originalRotation = transform.localRotation; }
// Use this for initialization protected virtual void Start() { SetInitialProperties(); characterController = GetComponent<CharacterController>(); control = GetComponent<Controller>(); motor = GetComponent<CharacterMotor>(); }
public void Start() { theCharacterMotor = GetComponent<CharacterMotor> (); jumpTimeCounter = jumpTime; groundCheckObj = transform.FindChild ("GroundCheck").gameObject; groundCheck = groundCheckObj.GetComponent<Collider2D> (); }
void Start() { playerMove = GetComponent<PlayerMove>(); characterMotor = GetComponent<CharacterMotor>(); DoDamage = GetComponent<DealDamage>(); PoundHitBox.enabled = false; }
void Awake() { m_charController = gameObject.AddComponent<CharacterController>(); m_charMotor = gameObject.AddComponent<CharacterMotor>(); IsMoving = false; CanMove = true; }
// Use this for initialization void Start() { Texture2D healthBackground = new Texture2D(1, 1); healthBackground.SetPixel(1, 1, Color.red); healthBackground.Apply(); style.normal.background = healthBackground; _motor = this.GetComponent<CharacterMotor>(); }
void Awake() { _charStatus = GetComponent<CharacterStatus> (); _charMotor = GetComponent<CharacterMotor> (); _charItem = GetComponent<CharacterItem> (); anim = GetComponent<Animator> (); _myAgent = GetComponentInChildren<NavMeshAgent> (); }
private float y = 0.0f; // Storing camera angle #endregion Fields #region Methods // Use this for initialization void Awake() { motor = GetComponent<CharacterMotor>(); game = GameObject.Find ("_GAMECORE").GetComponent<Game> (); if (!firstPersonCam) { firstPersonCam = (Camera)this.transform.FindChild ("PlayerView").GetComponent<Camera>(); } }
void Start() { _player = transform.root.GetComponentInChildren<PlayerController>(); _motor = transform.root.GetComponentInChildren<CharacterMotor>(); startY = transform.localPosition.y; bobbingSpeed = (2 * Mathf.PI) / transform.root.GetComponentInChildren<PlayerController>().footstepInterval; }
// Use this for initialization void Awake() { motor = GetComponent<CharacterMotor>(); if(networkView.isMine){ Camera.main.GetComponent<SmoothFollowSkull>().target = transform; } }
public int guardButtonPressed { get; private set; } // CharacterStatus accesses this when recovering from stun so we need it public. void Awake() { _anim = GetComponent<Animator> (); _charStatus = GetComponent<CharacterStatus> (); _charMotor = GetComponent<CharacterMotor>(); _charAttacking = GetComponent<CharacterAttacking> (); _charItem = GetComponent<CharacterItem> (); }
// Use this for initialization void Start() { leftBoundary = 0f; rightBoundary = 15f; playerObject = GameObject.Find("Player"); motor = playerObject.GetComponent<CharacterMotor>(); pic = playerObject.GetComponent<PlatformInputController>(); }
// Use this for initialization void Start() { //this sets the head variable to the Head component head = Camera.main.GetComponent<StereoController>().Head; //this gets the head component controller = GameObject.Find("PlayerCapsule"); //this finds the script that contains the boolean checkAutoWalk autowalk = controller.GetComponent<CharacterMotor>(); }
void Start() { motor = GetComponent<CharacterMotor>(); //set walking speed to default character motor walking speed walkSpeed = motor.movement.maxForwardSpeed; tr = transform; }
public void SyncPlayer(CharacterMotor m) { //Logger.Log("Syncing"); if (_stream != null && bConnected) { //SyncClient sync = new SyncClient(m.transform.position.x, m.transform.position.y, 0); // Serializer.SerializeWithLengthPrefix<SyncClient>(_stream, sync, PrefixStyle.Base128); // _stream.Flush(); } }
public void Update() { // TODO Remove test if (Input.GetKeyDown(KeyCode.F2)) { PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.Hoof); PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.Hoof); PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.Hoof); PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.Hoof); PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.Hoof); PlayerCharacterMasterController.instances[0].master.inventory.GiveItem(ItemIndex.BoostAttackSpeed); } if (Input.GetKeyDown(KeyCode.F3)) { //Get the player body to use a position: var transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform; //And then drop our defined item in front of the player. PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(driftItemDef.itemIndex), transform.position, transform.forward * 20f); } foreach (var status in SurvivorsToTrack) { CharacterMotor motor = status.CharacterBody.characterMotor; const float downForceGrounded = 0.5f; const float downForceInAir = 0.1f; int driftItemCount = status.CharacterBody.inventory.GetItemCount(driftItemDef.itemIndex); float dotResult = 1f; if (driftItemCount > 0) { const float frictionAmountMin = 0f; const float frictionAmountMax = 20f; const float frictionReductionTopSpeed = 200f; float frictionReductionAmount = 0; if (status.LastVelocity.magnitude > 0) { frictionReductionAmount = Mathf.Clamp01(status.LastVelocity.magnitude / frictionReductionTopSpeed); } // More friction while walking if (!status.CharacterBody.isSprinting) { frictionReductionAmount *= 0.8f; } float friction = Mathf.Lerp(frictionAmountMax, frictionAmountMin, frictionReductionAmount); Vector3 newVelocity = Vector3.Lerp(status.LastVelocity, motor.velocity, Time.deltaTime * friction); float downForce = motor.isGrounded ? downForceGrounded : downForceInAir; motor.velocity = new Vector3(newVelocity.x, motor.velocity.y - downForce, newVelocity.z); CharacterDirection direction = status.CharacterBody.characterDirection; dotResult = Vector2.Dot(new Vector2(status.LastVelocity.normalized.x, status.LastVelocity.normalized.z), new Vector2(direction.forward.normalized.x, direction.forward.normalized.z)); const float driftThreshold = 0.95f; const float driftSpeedThreshold = 5f; if (dotResult <= driftThreshold && new Vector2(newVelocity.x, newVelocity.z).magnitude >= driftSpeedThreshold) { driftPower += Mathf.Clamp01((1 - dotResult) * 2) * driftPowerBuildRate * Time.deltaTime; } } driftPower -= driftPowerDecayRate * Time.deltaTime; driftPower = Mathf.Clamp(driftPower, 0, driftPowerMax); int buffs = Mathf.FloorToInt((driftPower / driftPowerMax) * driftAttackSpeedBuff); if (currentDriftBuffCount != buffs) { while (currentDriftBuffCount < buffs) { status.CharacterBody.AddBuff(BuffIndex.AttackSpeedOnCrit); currentDriftBuffCount++; } while (currentDriftBuffCount > buffs) { status.CharacterBody.RemoveBuff(BuffIndex.AttackSpeedOnCrit); currentDriftBuffCount--; } Debug.Log($"Current Drift buff level is {currentDriftBuffCount}"); } // Update Music Volume Based On Current Velocity And Projected Velocity float passiveVolume = currentDriftBuffCount * currentDriftBuffCount; float activeVolume = dotResult <= 0.95f && motor.velocity.magnitude > 1f ? (1 - dotResult) * 50 : 0f; float targetVolume = passiveVolume * 0.85f + activeVolume * 0.15f; float newVolume = Mathf.Lerp(status.MusicVolume, targetVolume, Time.deltaTime * 15f); status.MusicVolume = newVolume; SetMusic(newVolume); status.LastVelocity = motor.velocity; } }
void Start() { m_motor = gameObject.GetComponent <CharacterMotor>(); //configureAnimations(); }
private void Start() { _cm = GameObject.FindObjectOfType <CharacterMotor>(); }
public void Equip(GameObject player) { Motor = player.GetComponent <CharacterMotor>(); isMounted = true; }
/// <summary> /// Initializes the state controller. /// </summary> public virtual void Initialize(GameObject reference) { characterMotor = reference.GetComponent <CharacterMotor>(); characterAnimation = reference.GetComponent <CharacterAnimation>(); }
void Start() { mainCamera = Camera.allCameras[1]; Screen.lockCursor = true; cmotor = GetComponent <CharacterMotor> (); }
private void CharacterMotor_FixedUpdate(On.RoR2.CharacterMotor.orig_FixedUpdate orig, CharacterMotor self) { if (self) { if (self.body.baseNameToken == "DG_SAMUS_NAME") { if (self.jumpCount == 1 && jumps == 0) { //Debug.Log("jumped"); jumps = 1; Util.PlaySound(SamusMod.Modules.Sounds.JumpSound, self.gameObject); } else if (self.jumpCount >= 2 && jumps + 1 == self.jumpCount) { //Debug.Log("djump"); jumps++; Util.PlaySound(SamusMod.Modules.Sounds.doubleJumpSound, self.gameObject); } } orig(self); } }
public static void SetUseGravity(this CharacterMotor motor, bool value) { typeof(CharacterMotor).GetProperty(nameof(CharacterMotor.useGravity)).GetSetMethod(true).Invoke(motor, new object[] { value }); }
void Awake() { cm = player.GetComponent <CharacterMotor>(); }
private void OnTriggerEnter(Collider other) { player = other.GetComponent <CharacterMotor>(); }
public virtual void OnUpdate(CharacterMotor motor) { motor.inputMoveDirection = _movableController.transform.rotation * _inputMoveDirection; motor.inputJump = _inputJump; }
private void Update() { var targetTransform = TargetOverride == null ? transform.parent : TargetOverride.transform; if (targetTransform == null) { return; } if (_cachedTransform != targetTransform) { _cachedTransform = targetTransform; _cachedAIController = _cachedTransform.GetComponent <AIController>(); _cachedMotor = _cachedTransform.GetComponent <CharacterMotor>(); } if (_cachedAIController == null) { return; } var character = Characters.Get(_cachedAIController.gameObject); if (character.Motor.IsAlive && !_cachedAIController.IsAlerted && (DisplayWhenAway || character.IsAnyInSight(0))) { _alpha += Time.deltaTime * FadeSpeed; } else { _alpha -= Time.deltaTime * FadeSpeed; } if (_cachedMotor != null) { var target = _cachedMotor.HeadLookTarget; target.y = transform.position.y; transform.LookAt(target); } _alpha = Mathf.Clamp01(_alpha); _mesh.Clear(); var vertexCount = Detail * 3; var indexCount = Detail * 3; if (_positions == null || _positions.Length != vertexCount) { _positions = new Vector3[vertexCount]; } if (_colors == null || _colors.Length != vertexCount) { _colors = new Color[vertexCount]; } if (_uv == null || _uv.Length != vertexCount) { _uv = new Vector2[vertexCount]; } var wasEdited = false; if (_alpha >= 1f / 255f) { wasEdited = true; var fov = _cachedAIController.View.FieldOfView * _alpha; var distance = _cachedAIController.View.SightDistance(_cachedAIController.IsAlerted); for (int i = 0; i < Detail; i++) { float a0 = fov * ((float)i / (float)Detail - 0.5f) + 90; float a1 = fov * ((float)(i + 1) / (float)Detail - 0.5f) + 90; _positions[i * 3 + 0] = Vector3.zero; _positions[i * 3 + 1] = new Vector3(Mathf.Cos(a1 * Mathf.Deg2Rad), 0, Mathf.Sin(a1 * Mathf.Deg2Rad)) * distance; _positions[i * 3 + 2] = new Vector3(Mathf.Cos(a0 * Mathf.Deg2Rad), 0, Mathf.Sin(a0 * Mathf.Deg2Rad)) * distance; } for (int i = 0; i < _colors.Length; i++) { _colors[i] = new Color(1, 1, 1, _alpha); } for (int i = 0; i < _uv.Length; i++) { _uv[i] = new Vector2((_positions[i].x / distance) * 0.5f + 0.5f, (_positions[i].z / distance) * 0.5f + 0.5f); } if (_indices == null || _indices.Length != indexCount) { _indices = new int[indexCount]; for (int i = 0; i < _indices.Length; i++) { _indices[i] = i; } } } if (wasEdited || !_hasSetAtLeastOnce) { _hasSetAtLeastOnce = true; _mesh.vertices = _positions; _mesh.colors = _colors; _mesh.uv = _uv; _mesh.triangles = _indices; } }
public _0024SubtractNewPlatformVelocity_0024168(CharacterMotor self_) { _0024self__0024171 = self_; }
// Use this for initialization void Awake() { motor = GetComponent <CharacterMotor>(); }
abstract public CharacterState StateMachine(CharacterMotor self);
protected override void Update() { base.Update(); _camera.fieldOfView = Util.Lerp(_camera.fieldOfView, FOV, 6); var forwardVector = transform.forward; forwardVector.y = 0; if (forwardVector.magnitude < float.Epsilon) { forwardVector = Vector3.forward; } else { forwardVector.Normalize(); } var rightVector = Vector3.Cross(Vector3.up, forwardVector); var forwardSpeed = Vector3.Dot(_velocity, forwardVector); var rightSpeed = Vector3.Dot(_velocity, rightVector); var forwardTarget = 0f; var rightTarget = 0f; if (_lastTarget != Target) { _lastTarget = Target; _travelStart = transform.position; _targetTravel = 0; } if (FollowTarget && Target != null) { var targetPosition = Target.transform.position; targetPosition.y += 2; var diff = transform.position.y - Target.transform.position.y; targetPosition.y += diff; targetPosition -= forwardVector * diff; if (_targetTravel < 1 - float.Epsilon) { var t = _targetTravel; t = t * t * (3 - 2 * t); targetPosition = _travelStart + (targetPosition - _travelStart) * t; _targetTravel = Mathf.Clamp01(_targetTravel + Time.deltaTime / TargetTransitionDuration); } var move = (targetPosition - transform.position) / Time.deltaTime; forwardSpeed = Vector3.Dot(move, forwardVector); rightSpeed = Vector3.Dot(move, rightVector); } else { _targetTravel = 0; _travelStart = transform.position; if (Input.GetKey(KeyCode.W)) { forwardTarget = 1; } if (Input.GetKey(KeyCode.S)) { forwardTarget = -1; } if (Input.GetKey(KeyCode.D)) { rightTarget = 1; } if (Input.GetKey(KeyCode.A)) { rightTarget = -1; } Util.Lerp(ref forwardSpeed, forwardTarget * Speed, Acceleration); Util.Lerp(ref rightSpeed, rightTarget * Speed, Acceleration); } _velocity = forwardVector * forwardSpeed + rightVector * rightSpeed; transform.position += _velocity * Time.deltaTime; _heightOffset = Mathf.Clamp(transform.position.y + _heightOffset - Input.mouseScrollDelta.y * HeightSpeed * 0.5f, MinHeight, MaxHeight) - transform.position.y; { var move = Mathf.Clamp(Time.deltaTime * 10, 0, Mathf.Abs(_heightOffset)) * Mathf.Sign(_heightOffset); transform.position += Vector3.up * move; transform.position -= forwardVector * move; _heightOffset -= move; } }
void Start() { motor = GetComponent <CharacterMotor>(); }
private void Awake() { _motor = GetComponent <CharacterMotor>(); }
override public void setCharacterMotor(CharacterMotor motor) { this.motor = motor; }
// Use this for initialization void Start() { holdingBall = false; motor = GetComponent <CharacterMotor>(); }
// Use this for initialization void Start() { playerCollider = transform.parent.GetComponent <Collider> (); characterMotor = transform.parent.GetComponent <CharacterMotor> (); }
private void CharacterMotor_OnLanded(On.RoR2.CharacterMotor.orig_OnLanded orig, CharacterMotor self) { if (self) { if (self.body.baseNameToken == "DG_SAMUS_NAME" && jumps > 0) { jumps = 0; } orig(self); } }
// Use this for initialization void Awake() { motor = GetComponent <CharacterMotor>(); ch = GetComponent <CharacterController> (); height = ch.height; }
void Start() { cameraOverlay = GameObject.Find("cameraOverlay"); characterMotor = GameObject.Find("First Person Controller").GetComponent <CharacterMotor>(); }
public void Awake() { this.motor = (CharacterMotor)this.GetComponent(typeof(CharacterMotor)); }
internal static void CreatePrefab() { Debug.LogWarning("In CreatePrefab"); // first clone the commando prefab so we can turn that into our own survivor characterPrefab = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody"), "ExampleSurvivorBody", true, "/home/sirhamburger/Git/Risk-of-Rain-2-Guts-Code/ExampleSurvivor/ExampleSurvivor/ExampleSurvivor/ExampleSurvivor/ExampleSurvivor.cs", "CreatePrefab", 151); if (characterPrefab == null) { Debug.LogError("characterPrefab == null"); } characterPrefab.GetComponent <NetworkIdentity>().localPlayerAuthority = true; // create the model here, we're gonna replace commando's model with our own GameObject model = CreateModel(characterPrefab); gutsModel = model; Debug.LogWarning("before get ModelBase"); GameObject gameObject = new GameObject("ModelBase"); gameObject.transform.parent = characterPrefab.transform; gameObject.transform.localPosition = new Vector3(0f, -0.81f, 0f); gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = new Vector3(1.3f, 1.3f, 1.3f); Debug.LogWarning("before get CameraPivot"); GameObject gameObject2 = new GameObject("CameraPivot"); gameObject2.transform.parent = gameObject.transform; gameObject2.transform.localPosition = new Vector3(0f, 1.6f, 0f); gameObject2.transform.localRotation = Quaternion.identity; gameObject2.transform.localScale = Vector3.one; Debug.LogWarning("before get AimOrigin"); GameObject gameObject3 = new GameObject("AimOrigin"); if (gameObject == null) { Debug.LogError("GameIbject ==null") ; } gameObject3.transform.parent = gameObject.transform; gameObject3.transform.localPosition = new Vector3(0f, 1.4f, 0f); gameObject3.transform.localRotation = Quaternion.identity; gameObject3.transform.localScale = Vector3.one; if (model == null) { Debug.LogError("model ==null"); } Transform transform = model.transform; transform.parent = gameObject.transform; transform.localPosition = Vector3.zero; transform.localScale = new Vector3(1.01f, 1.01f, 1.01f); transform.localRotation = Quaternion.identity; Debug.LogWarning("before get CharacterDirection"); CharacterDirection characterDirection = characterPrefab.GetComponent <CharacterDirection>(); characterDirection.moveVector = Vector3.zero; characterDirection.targetTransform = gameObject.transform; characterDirection.overrideAnimatorForwardTransform = null; characterDirection.rootMotionAccumulator = null; characterDirection.modelAnimator = model.GetComponentInChildren <Animator>(); characterDirection.driveFromRootRotation = false; characterDirection.turnSpeed = 720f; // set up the character body here CharacterBody bodyComponent = characterPrefab.GetComponent <CharacterBody>(); bodyComponent.bodyIndex = -1; bodyComponent.baseNameToken = "EXAMPLESURVIVOR_NAME"; // name token bodyComponent.subtitleNameToken = "EXAMPLESURVIVOR_SUBTITLE"; // subtitle token- used for umbras bodyComponent.bodyFlags = CharacterBody.BodyFlags.ImmuneToExecutes; bodyComponent.rootMotionInMainState = false; bodyComponent.mainRootSpeed = 0; bodyComponent.baseMaxHealth = 90; bodyComponent.levelMaxHealth = 24; bodyComponent.baseRegen = 0.5f; bodyComponent.levelRegen = 0.25f; bodyComponent.baseMaxShield = 0; bodyComponent.levelMaxShield = 0; bodyComponent.baseMoveSpeed = 7; bodyComponent.levelMoveSpeed = 0; bodyComponent.baseAcceleration = 80; bodyComponent.baseJumpPower = 15; bodyComponent.levelJumpPower = 0; bodyComponent.baseDamage = 15; bodyComponent.levelDamage = 3f; bodyComponent.baseAttackSpeed = 1; bodyComponent.levelAttackSpeed = 0; bodyComponent.baseCrit = 1; bodyComponent.levelCrit = 0; bodyComponent.baseArmor = 0; bodyComponent.levelArmor = 0; bodyComponent.baseJumpCount = 1; bodyComponent.sprintingSpeedMultiplier = 1.45f; bodyComponent.wasLucky = false; bodyComponent.hideCrosshair = false; bodyComponent.aimOriginTransform = gameObject3.transform; bodyComponent.hullClassification = HullClassification.Human; bodyComponent.portraitIcon = Assets.charPortrait; bodyComponent.isChampion = false; bodyComponent.currentVehicle = null; bodyComponent.skinIndex = 0U; Debug.LogWarning("before get CharacterMotor"); // the charactermotor controls the survivor's movement and stuff CharacterMotor characterMotor = characterPrefab.GetComponent <CharacterMotor>(); characterMotor.walkSpeedPenaltyCoefficient = 1f; characterMotor.characterDirection = characterDirection; characterMotor.muteWalkMotion = false; characterMotor.mass = 100f; characterMotor.airControl = 0.25f; characterMotor.disableAirControlUntilCollision = false; characterMotor.generateParametersOnAwake = true; InputBankTest inputBankTest = characterPrefab.GetComponent <InputBankTest>(); inputBankTest.moveVector = Vector3.zero; Debug.LogWarning("before get CameraTargetParams"); CameraTargetParams cameraTargetParams = characterPrefab.GetComponent <CameraTargetParams>(); cameraTargetParams.cameraParams = Resources.Load <GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponent <CameraTargetParams>().cameraParams; cameraTargetParams.cameraPivotTransform = null; cameraTargetParams.aimMode = CameraTargetParams.AimType.Standard; cameraTargetParams.recoil = Vector2.zero; cameraTargetParams.idealLocalCameraPos = Vector3.zero; cameraTargetParams.dontRaycastToPivot = false; // this component is used to locate the character model(duh), important to set this up here Debug.LogWarning("before get ModelLocator"); ModelLocator modelLocator = characterPrefab.GetComponent <ModelLocator>(); modelLocator.modelTransform = transform; modelLocator.modelBaseTransform = gameObject.transform; modelLocator.dontReleaseModelOnDeath = false; modelLocator.autoUpdateModelTransform = true; modelLocator.dontDetatchFromParent = false; modelLocator.noCorpse = false; modelLocator.normalizeToFloor = false; // set true if you want your character to rotate on terrain like acrid does modelLocator.preserveModel = false; // childlocator is something that must be set up in the unity project, it's used to find any child objects for things like footsteps or muzzle flashes // also important to set up if you want quality Debug.LogWarning("before get ChildLocator"); ChildLocator childLocator = model.GetComponent <ChildLocator>(); ExampleSurvivor.childLocator = childLocator; // this component is used to handle all overlays and whatever on your character, without setting this up you won't get any cool effects like burning or freeze on the character // it goes on the model object of course Debug.LogWarning("before add CharacterModel"); CharacterModel characterModel = model.AddComponent <CharacterModel>(); characterModel.body = bodyComponent; //Debug.LogError("model.GetComponentInChildren<SkinnedMeshRenderer>().name: " + model.GetComponentInChildren<SkinnedMeshRenderer>().material.name); // // foreach(var element in characterModel.baseRendererInfos) // Debug.LogError(element.defaultMaterial.name); //characterModel.baseRendererInfos = new CharacterModel.RendererInfo[model.GetComponentInChildren<SkinnedMeshRenderer>().materials.Length]; //int pos = 0; //foreach(var material in model.GetComponentInChildren<SkinnedMeshRenderer>().materials) //{ // characterModel.baseRendererInfos[pos] = // new CharacterModel.RendererInfo // { // defaultMaterial = material, // renderer =model.GetComponentInChildren<SkinnedMeshRenderer>(), // defaultShadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On, // ignoreOverlays = false // // }; // pos++; // Debug.LogWarning(material.name); //} //foreach(var element in characterModel.baseRendererInfos) // Debug.LogError(element.defaultMaterial.name); // characterModel.autoPopulateLightInfos = true; characterModel.invisibilityCount = 0; characterModel.temporaryOverlays = new List <TemporaryOverlay>(); Debug.LogWarning("before add TeamComponent"); TeamComponent teamComponent = null; if (characterPrefab.GetComponent <TeamComponent>() != null) { teamComponent = characterPrefab.GetComponent <TeamComponent>(); } else { teamComponent = characterPrefab.GetComponent <TeamComponent>(); } teamComponent.hideAllyCardDisplay = false; teamComponent.teamIndex = TeamIndex.None; HealthComponent healthComponent = characterPrefab.GetComponent <HealthComponent>(); healthComponent.health = 90f; healthComponent.shield = 0f; healthComponent.barrier = 0f; healthComponent.magnetiCharge = 0f; healthComponent.body = null; healthComponent.dontShowHealthbar = false; healthComponent.globalDeathEventChanceCoefficient = 1f; characterPrefab.GetComponent <Interactor>().maxInteractionDistance = 3f; characterPrefab.GetComponent <InteractionDriver>().highlightInteractor = true; // this disables ragdoll since the character's not set up for it, and instead plays a death animation CharacterDeathBehavior characterDeathBehavior = characterPrefab.GetComponent <CharacterDeathBehavior>(); characterDeathBehavior.deathStateMachine = characterPrefab.GetComponent <EntityStateMachine>(); characterDeathBehavior.deathState = new SerializableEntityStateType(typeof(GenericCharacterDeath)); Debug.LogWarning("before add SfxLocator"); // edit the sfxlocator if you want different sounds SfxLocator sfxLocator = characterPrefab.GetComponent <SfxLocator>(); sfxLocator.deathSound = "Play_ui_player_death"; sfxLocator.barkSound = ""; sfxLocator.openSound = ""; sfxLocator.landingSound = "Play_char_land"; sfxLocator.fallDamageSound = "Play_char_land_fall_damage"; sfxLocator.aliveLoopStart = ""; sfxLocator.aliveLoopStop = ""; Debug.LogWarning("before get Rigidbody"); Rigidbody rigidbody = characterPrefab.GetComponent <Rigidbody>(); rigidbody.mass = 100f; rigidbody.drag = 0f; rigidbody.angularDrag = 0f; rigidbody.useGravity = false; rigidbody.isKinematic = true; rigidbody.interpolation = RigidbodyInterpolation.None; rigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete; rigidbody.constraints = RigidbodyConstraints.None; Debug.LogWarning("before get CapsuleCollider"); CapsuleCollider capsuleCollider = characterPrefab.GetComponent <CapsuleCollider>(); capsuleCollider.isTrigger = false; capsuleCollider.material = null; capsuleCollider.center = new Vector3(0f, 0f, 0f); capsuleCollider.radius = 0.5f; capsuleCollider.height = 1.82f; capsuleCollider.direction = 1; Debug.LogWarning("before get KinematicCharacterMotor"); KinematicCharacterMotor kinematicCharacterMotor = characterPrefab.GetComponent <KinematicCharacterMotor>(); kinematicCharacterMotor.CharacterController = characterMotor; kinematicCharacterMotor.Capsule = capsuleCollider; kinematicCharacterMotor.Rigidbody = rigidbody; capsuleCollider.radius = 0.5f; capsuleCollider.height = 1.82f; capsuleCollider.center = new Vector3(0, 0, 0); capsuleCollider.material = null; kinematicCharacterMotor.DetectDiscreteCollisions = false; kinematicCharacterMotor.GroundDetectionExtraDistance = 0f; kinematicCharacterMotor.MaxStepHeight = 0.2f; kinematicCharacterMotor.MinRequiredStepDepth = 0.1f; kinematicCharacterMotor.MaxStableSlopeAngle = 55f; kinematicCharacterMotor.MaxStableDistanceFromLedge = 0.5f; kinematicCharacterMotor.PreventSnappingOnLedges = false; kinematicCharacterMotor.MaxStableDenivelationAngle = 55f; kinematicCharacterMotor.RigidbodyInteractionType = RigidbodyInteractionType.None; kinematicCharacterMotor.PreserveAttachedRigidbodyMomentum = true; kinematicCharacterMotor.HasPlanarConstraint = false; kinematicCharacterMotor.PlanarConstraintAxis = Vector3.up; kinematicCharacterMotor.StepHandling = StepHandlingMethod.None; kinematicCharacterMotor.LedgeHandling = true; kinematicCharacterMotor.InteractiveRigidbodyHandling = true; kinematicCharacterMotor.SafeMovement = false; // this sets up the character's hurtbox, kinda confusing, but should be fine as long as it's set up in unity right Debug.LogWarning("before get HurtBoxGroup"); HurtBoxGroup hurtBoxGroup = model.AddComponent <HurtBoxGroup>(); HurtBox componentInChildren = model.GetComponentInChildren <CapsuleCollider>().gameObject.AddComponent <HurtBox>(); componentInChildren.gameObject.layer = LayerIndex.entityPrecise.intVal; componentInChildren.healthComponent = healthComponent; componentInChildren.isBullseye = true; componentInChildren.damageModifier = HurtBox.DamageModifier.Normal; componentInChildren.hurtBoxGroup = hurtBoxGroup; componentInChildren.indexInGroup = 0; hurtBoxGroup.hurtBoxes = new HurtBox[] { componentInChildren }; hurtBoxGroup.mainHurtBox = componentInChildren; hurtBoxGroup.bullseyeCount = 1; // this is for handling footsteps, not needed but polish is always good Debug.LogWarning("before get FootstepHandler"); FootstepHandler footstepHandler = model.AddComponent <FootstepHandler>(); footstepHandler.baseFootstepString = "Play_player_footstep"; footstepHandler.sprintFootstepOverrideString = ""; footstepHandler.enableFootstepDust = true; footstepHandler.footstepDustPrefab = Resources.Load <GameObject>("Prefabs/GenericFootstepDust"); // ragdoll controller is a pain to set up so we won't be doing that here.. RagdollController ragdollController = model.AddComponent <RagdollController>(); ragdollController.bones = null; ragdollController.componentsToDisableOnRagdoll = null; // this handles the pitch and yaw animations, but honestly they are nasty and a huge pain to set up so i didn't bother Debug.LogWarning("before add AimAnimator"); AimAnimator aimAnimator = model.AddComponent <AimAnimator>(); aimAnimator.inputBank = inputBankTest; aimAnimator.directionComponent = characterDirection; aimAnimator.pitchRangeMax = 55f; aimAnimator.pitchRangeMin = -50f; aimAnimator.yawRangeMin = -44f; aimAnimator.yawRangeMax = 44f; aimAnimator.pitchGiveupRange = 30f; aimAnimator.yawGiveupRange = 10f; aimAnimator.giveupDuration = 8f; Debug.LogWarning("finished CreatePrefab"); }
void OnEnable() { monobehaviour = target as CharacterMotor; }
// Use this for initialization void Awake() { motor = GetComponent <CharacterMotor>(); animator = GetComponentInChildren <Animator>(); }
private void Awake() { _animator = GetComponent <Animator>(); _body = GetComponent <Rigidbody>(); _motor = GetComponent <CharacterMotor>(); }
/// <summary> /// Method which retrieves all the references for the above variables. /// </summary> protected virtual void Awake() { //Assign Camera Control Variable if (Camera.main.GetComponent <CameraControl>()) { m_Camera = Camera.main.GetComponent <CameraControl>(); } else { Debug.LogError(Camera.main.name + " requires component : CameraControl"); } //Assign Input Manager Variable if the character uses user input. if (GetComponent <InputManager>()) { m_Input = GetComponent <InputManager>(); } //Assign Input Manager Variable if the character uses user input. if (GetComponentInChildren <AudioSource>()) { m_Audio = GetComponentInChildren <AudioSource>(); } //Assign Rigidbody Variable if (GetComponent <Rigidbody>()) { m_Rigidbody = GetComponent <Rigidbody>(); } else if (GetComponentInChildren <Rigidbody>()) { m_Rigidbody = GetComponentInChildren <Rigidbody>(); } else if (GetComponentInParent <Rigidbody>()) { m_Rigidbody = GetComponentInParent <Rigidbody>(); } else { Debug.LogError(transform.name + " requires component : Rigidbody"); } //Assign Character Motor Variable if (GetComponent <CharacterMotor>()) { m_Motor = GetComponent <CharacterMotor>(); } else if (GetComponentInChildren <CharacterMotor>()) { m_Motor = GetComponentInChildren <CharacterMotor>(); } else if (GetComponentInParent <CharacterMotor>()) { m_Motor = GetComponentInParent <CharacterMotor>(); } else { Debug.Log(transform.name + " does not have component : CharacterMotor."); } //Assign Animator Variable if (GetComponent <Animator>()) { m_Animator = GetComponent <Animator>(); } else if (GetComponentInChildren <Animator>()) { m_Animator = GetComponentInChildren <Animator>(); } else if (GetComponentInParent <Animator>()) { m_Animator = GetComponentInParent <Animator>(); } //Assign Material Variable if (GetComponent <SkinnedMeshRenderer>()) { m_Material = GetComponent <SkinnedMeshRenderer>().material; } else if (GetComponentInChildren <SkinnedMeshRenderer>()) { m_Material = GetComponentInChildren <SkinnedMeshRenderer>().material; } else if (GetComponent <MeshRenderer>()) { m_Material = GetComponent <MeshRenderer>().material; } else if (GetComponentInChildren <MeshRenderer>()) { m_Material = GetComponentInChildren <MeshRenderer>().material; } else { Debug.Log(transform.name + " does not have a Material assigned to either a Mesh Renderer or a SkinnedMeshRenderer."); } }