Hello! Im working on a space simulation project. The script that im using to replicate “space movement” only goes forward and backward. I need it (or another script) to let me go side to side when I press a button on my gamepad. I know how to select the correct button, just need to know how to make it strafe.
The script is below, the object it is attached to has a rigidbody, constant force, and the mouselook script attached to it!
Thanks in advance for the help!
Wasteland
private var pilot : Rigidbody;
var thrustForce = 3;
function Awake()
{
pilot = rigidbody;
}
var invertPitch : boolean = true;
var invertYaw : boolean = false;
var sensitivity : float = 1000;
function Update ()
{
if (Input.GetKeyDown("joystick button 1"))
SetThrust(30);
// other ifs here
if (Input.GetKeyUp("joystick button 1"))
{
SetThrust(0);
}
if (Input.GetKeyDown("joystick button 3"))
{
SetThrust(-50);
}
if (Input.GetKeyUp("joystick button 3"))
{
SetThrust(0);
}
}
function SetThrust ( thrustForce : int)
{
pilot.constantForce.relativeForce = Vector3.forward * thrustForce * sensitivity;
}