- Home /
Question by
Levithan6785 · May 29, 2015 at 05:22 AM ·
directionrigidbody.velocitycombinediagonal
C# rigidbody.velocity diagonal movement
I've decided to rework the movement system of my fps game because the old one made me clip through walls when using transform.translate for example instead of rigidbody velocity. However, the old system allowed a diagonal movement when pressing the "w" and "a" key for example creating a forward strafing movement. However, the new system I have prevents the clip through walls problem but doesn't allow the combined diagonal strafe affect i'd like from the previous movement system
New:
rb.velocity = transform.TransformDirection(Vector3.forward) * walkSpeed;
Old:
transform.translate((Vector3.forward) * walkSpeed * Time.deltaTime);
The code above was used for the "w" key, and there are others for the other 3, "a""s","d" respectively. I'm curious to know how get the combined affect I'm looking for like with the old line of code.
Comment