// Start is called before the first frame update protected void Awake() { spiderSpecificConstants = gameObject.GetComponent <SpiderSpecificConstants>(); animator = gameObject.GetComponent <SpiderAnimator>(); initialPosition = transform.position; initialRotation = transform.rotation; UpdateScaleMultiplier(); //Debug.Log(gameObject.name + ": scale = " + scaleMultiplier); }
private void MoveRigidBody() { IsWalking = false; Climb(); if (!GameData.IsGamePaused) { // translate spider if (Input.GetKey(KeyCode.W)) { transform.position += transform.forward * MoveSpeed * Time.deltaTime; IsWalking = true; } else if (Input.GetKey(KeyCode.S)) { transform.position -= transform.forward * MoveSpeed * Time.deltaTime; IsWalking = true; } if (Input.GetKey(KeyCode.D)) { transform.position += transform.right * MoveSpeed * Time.deltaTime; IsWalking = true; } else if (Input.GetKey(KeyCode.A)) { transform.position -= transform.right * MoveSpeed * Time.deltaTime; IsWalking = true; } // rotate spider RotateAmount = Input.GetAxis("Mouse X") * RotateSpeed * Time.deltaTime; transform.RotateAround(transform.position, transform.up, RotateAmount); IsWalking = RotateAmount != 0.0f ? true : IsWalking; } // make sure spider sticks to surface RigidBody.velocity = -transform.up * RigidBody.mass; // animate if (SpiderAnimator) { SpiderAnimator.SetBool("IsWalking", IsWalking); } }