Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Space Shooter

Discussion in 'Editor & General Support' started by NobleRogue, Apr 27, 2015.

  1. NobleRogue

    NobleRogue

    Joined:
    Apr 20, 2015
    Posts:
    8
    I am relatively new to Unity. I have completed the Roll-A-Ball tutorial and have moved on to the Space Shooter Tutorial. I have two questions. One, when do yall think Space Shooter will be updated for Unity 5? My second question is a little more technical. Not having a reliable 5.0 tutorial, I have had to make a go of it on my own. I have come across one issue at this point that I can not seem to resolve. My player moves but I cant adjust its speed. Here is a copy of my current script. Thank You for any help yall might provide.
    using UnityEngine;

    using System.Collections;
    public class PlayerController : MonoBehaviour
    {

    public float speed;
    public Rigidbody rb;

    void Start()
    {
    rb = GetComponent<Rigidbody> ();
    }

    void FixedUpdate ()
    {
    float moveHorizontal = Input.GetAxis ("Horizontal");
    float moveVertical = Input.GetAxis ("Vertical");
    if (Input.GetButton ("Horizontal"))
    rb.velocity = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    if (Input.GetButton ("Vertical"))
    rb.velocity = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    }
    }
    P.S.
    I did try to combine the two "if (Input.GetButton......." parts of the scrip but it would only let my player move diagonally. I did it like this. "if (Input.GetButton ("Horizontal", "Vertical"))" and I got the message about two arguments where only one can exist. If yall have any other suggestions on how I might simplify that particular text for 5.0, so it's not redundant or using unnecessary memory, I would appreciate it. Thanks again yall.
     
  2. NobleRogue

    NobleRogue

    Joined:
    Apr 20, 2015
    Posts:
    8
    problem solved