FPS changing Rigidbody.velocity works on player but not on enemy
Hi, I'm making a FPS game and currently there is only the player and one monster (enemy). When I set WASD to change my player's velocity. Everything works fine. However, when I want to let the monster move by changing its Rigidbody.velocty, It doesn't work......
Basically, I did this to my player, with public RigidBody.
Vector3 movDirection = Vector3.zero;
if (Input.GetKey (KeyCode.W)) {movDirection.z += 1;}
if (Input.GetKey (KeyCode.S)) {movDirection.z -= 1;}
if (Input.GetKey (KeyCode.A)) {movDirection.x -= 1;}
if (Input.GetKey (KeyCode.D)) {movDirection.x += 1;}
movDirection = movDirection.normalized;
Vector3 velocity = rigidBody.velocity;
velocity.x = movDirection.x * MoveSpeed;
velocity.z = movDirection.z * MoveSpeed;
rigidBody.velocity = velocity;
And this to the moster object in Update().
rigidBody.velocity = this.transform.forward * MoveSpeed;
No matter what number I set to MoveSpeed, I print out rigidBody.velocity and they were all tiny vectors and not equal to this.transform.forward * MoveSpeed.
I'm really confused since these two are basically the same. I understand that using Rigidbody.velocity may cause unrealistic behavior but that's not my concern here. Please help thanks.
Your answer
Follow this Question
Related Questions
RigidBody Controller Forces 0 Answers
Why is new Vector3 stronger when player is in the air? 0 Answers
Rocket Landing 1 Answer
How to throw an object towards a hit.point in first person? 0 Answers