The start simply contains the rigidbody reference. Now the issue here is, when the player/character/cube thing is facing away from the camera, it moves away if I press W (or up), if I press A it moves left, D for right, and S towards the camera.
The problem is when facing up and then I press down or press down and then press up or press left and then press right or press right and then press left, it does turn 180 degrees on the Y, however there’s a strafe on the X axis of the transform.position, as if it did a snapping slow turn to the opposite direction.
Can someone please explain why this is happening and how I can fix it? How can I make the character turn the opposite direction without the strafing ?I think I am missing something with transform.right …
bm950
Hi still a noob and still learning but peoples help here, so I try to helps to.
if you have a rigid body never play directly with transform. it might caus bug.
if your rigid body is kinematic = false don’t play directly with velocity. the physic system don’t like that.
try instead using: addforce(“what ever variable or input you lie”, Forcemode.“1 of the 4 forcemode”)
same thing with addtorque(to turn).
personaly I prefere to use AddRelativeForce and AddRelativeTorque, but that just depend on how you use your camera.
for point 3, an example of my script : rb.AddRelativeForce(Vector3.forward* forward, ForceMode.Acceleration);
rb.AddRelativeTorque(Vector3.up * rotation, ForceMode.Acceleration);
basicaly, AddForce (vector3.forward) tell unity: this object go “north”
and AddRelativeForce (vector3.forward) tell unity this object move on IS foward axis.
yup. I’m a noob so sorry if it’s not clair. trying to help.
So make sure the mesh’s “local origin” is in the center of the model itself. This here is a cube model, so I just selected “Center pivot” and just put 0,0,0 on my collider’s positioning. Now it looks perfect! Look at this!e4dfi
I am so happy with this result. I learned something!
For the jump slowness make sure you don’t have a Time.deltaTime on the rigidbody.velocity.y, in a lot of movement tutorials (that don’t use velocity) they put a 0 on the y axis. So when I had 0, the object fell slowly but if you just put the y velocity instead of 0, it should fall normally. You can even control the speed of fall by substituting a variable there too.