- Home /
Movement problem?
I have two spheres.One large one small. The small one is on the large one. Now I am moving the small sphere on the large force. But I can't move it the way I want it too.
The Gravity on the sphere:
 rigidbody.velocity = (-transform.position + planet.transform.position) * gravity ;
The Movement Script:
 if(Input.GetKey(KeyCode.A))
         {
             rigidbody.AddForce(Vector3.right * speed);
             
         }
         if(Input.GetKey(KeyCode.S))
         {
             rigidbody.AddForce(Vector3.down * speed);
             
         }
         if(Input.GetKey(KeyCode.D))
         {
             rigidbody.AddForce(Vector3.left * speed);
             
         }
         if(Input.GetKey(KeyCode.W))
         {
             rigidbody.AddForce(Vector3.forward * speed);
             
         }
The placement of forces may be wrong.But in order to make the small rotate around the large one my keys change some way. Like first was "S" , then "A" and then "D".
Not sure it is going to solve your problems, but as a start try this:
- Replace 'Vector3.right' with 'transform.right' 
- Replace 'Vector3.down' with '-transform.up' 
- Replace 'Vector3.left' with '-transform.right' 
- Replace 'Vector3.forward' with 'transform.forward' 
Getting rotating around a sphere to look right can be a hard problem. It depends on how you have everything setup.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                