c# - Unity3d Local Forward -
i trying move rigidbody forward in local coordinates, mean, if rotate want move in local x axis.
i have tried this, moves in global coordinates:
rigidbody player = getcomponent<rigidbody>(); vector3 movement = new vector3 (1.0f, 0.0f, 0.0f); movement = movement.normalized * 2 * time.deltatime; player.moveposition(transform.position + movement);
i don't know how make change local coordinates.
moveposition works in world space, have this:
rigidbody player = getcomponent<rigidbody>(); // hope you're not doing every frame, btw float speed = 2f; // magic numbers bad, move them variables, @ least vector3 movement = transform.forward * speed * time.deltatime; player.moveposition(transform.position + movement);
Comments
Post a Comment