- Home /
 
               Question by 
               birdinabox · Jul 06, 2011 at 04:49 AM · 
                axiscontrolspaceship  
              
 
              force too -z ax
Hey guys, basicly im making a space ship game, and was wondering if you new a script so when I pushed the up arrow, it pushes it along the -z axis, as if the engine was pushing it.
Thanks again! :)
               Comment
              
 
               
              Answer by asafsitner · Jul 06, 2011 at 07:33 AM
(I'm a C# user, so implement the idea according to what you write in)
 using UnityEngine;
 using System.Collections;
 
 public class Move : MonoBehaviour 
 {
     public float engineThrust = 5.0f;
     
     void Update() 
     {
          var z = Input.GetAxis("Vertical") * Time.deltaTime * engineThrust;
          transform.translate (0,0,z);
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
AirPlane Script? 2 Answers
Good prefab/assest to buy for FPS style shooter iOS? 0 Answers
Problem with quaternion rotation zxis 0 Answers
How do you make an orbit enemy ai? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                