- Home /
Moving a sphere that rotates "up" using addforce or something similar
This is my small script so far: using UnityEngine; using System.Collections;
public class wcheck5 : MonoBehaviour {
 public float ballSpeed;
 public float thrust;
 // Update is called once per frame
 void Update()
 {
     float xSpeed = Input.GetAxis("Horizontal");
     float ySpeed = Input.GetAxis("Vertical");
     Rigidbody body = GetComponent<Rigidbody>();
     body.AddTorque(new Vector3(xSpeed, 0, ySpeed) * ballSpeed * Time.deltaTime);
     if (Input.GetKey("space"))
     {
         body.AddForce(transform.forward * thrust);
     }
 }
}
The sphere rotates when it moves so when the force is added by the space bar being pressed, the sphere isnt just going "forward" it is going in whatever directing the sphere is spinning at. Anyone know how I can lock it so it only goes in one directiopn regardless of its rotation, maybe using global spacer instead of local spacE? Thanks for any help
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                