- Home /
Move 3D rigidbody sphere in the direction of it's rotation, controlled by the mouse.
Introduction:
I'm new to Unity and it is my first project. Even tho moving sphere based on world's directions is not that difficult and has various guides explaining how to do it in a variety of ways. I was unable to find anything that works for my case.
What have I tried so far:
transform.position — Kinda works, but is in no way realistic.
RigidBody.addForce — Only moves object relative to the world's directions.
RigidBody.addRelativeForce — Has my highest hopes so far, but due to insane spinning in Z axes it forces the sphere to turn around each time the sphere rotates. Also sometimes it just launches the sphere to the moon. Would be nice if there is a way to add force relative to X rotation only, however I was not able to find info about that.
CharacterController — almost span the sphere at mark 2 out of my monitor.
Code I use for the sphere's rotation:
float rotationSpeed = 1.5f;
transform.eulerAngles += rotationSpeed * new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0);
TLDR: I need something that allows sphere to move in direction of its X rotation while still maintaining all properties of the rigidbody and hopefully lock its rotation in x axes to only be affected by the mouse.
P.S
Yes, I know I have to read the manual. I have read the parts which I consider relevant to the case due to the low cpabilities of my brain, I was unable to apply information from the manual properly.