Question by 
               adude172 · Apr 01, 2018 at 01:28 AM · 
                scripting problemmovementscripting beginnertop down shooter  
              
 
              Why can I only move upwards?
I'm trying to get this script to let me move upwards using W, and also let me turn side to side using A and D. I'm very new to Unity and C#, so I'm not sure what's going on, could anyone help? here's the script.
Thanks!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by adude172 · Apr 01, 2018 at 04:08 AM
I managed to find an answer! Here's what I did:
//private Rigidbody2D myRigidbody; [SerializeField] private float playerSpeed = 10; [SerializeField] private float turnSpeed = 10; // Use this for initialization void Start () { //myRigidbody = GetComponent<Rigidbody2D>(); } // Update is called once per frame void Update () { MoveForward(); // Player Movement TurnRightAndLeft();//Player Turning } void MoveForward (){ if(Input.GetKey("w"))//Press up arrow key to move forward on the Y AXIS { transform.Translate(0,playerSpeed * Time.deltaTime,0); } } void TurnRightAndLeft (){ if(Input.GetKey("d")) //Right arrow key to turn right { transform.Rotate(-Vector3.forward *turnSpeed* Time.deltaTime); } if(Input.GetKey("a"))//Left arrow key to turn left { transform.Rotate(Vector3.forward *turnSpeed* Time.deltaTime); } }}
Just posting in case anyone for some reason ever wants it. :)
Your answer
 
 
             Follow this Question
Related Questions
Script problems c# 0 Answers
Rigidbody2D movement is lagging 0 Answers
Player not moving in the right direction instantly 1 Answer
1st Person shooter, move player forward where cam is facing 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                