Search Unity

Space Shooter Tutorial Issues

Discussion in 'Getting Started' started by kengkendall, Dec 8, 2018.

  1. kengkendall

    kengkendall

    Joined:
    Dec 5, 2018
    Posts:
    1
    Running Unity 2018 2.18 Spaceshooter tutorial has compiler errors on player controller script. Followed the Tutorial but did not work up to this section. Even on the completed scene. Should I discontinue this tutorial?

    Error after saving is:

    Assets/Scripts/PlayerController.cs(14,19): error CS1061: Type `UnityEngine.Component' does not contain a definition for `velocity' and no extension method `velocity' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?

    Tutorial Script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.  
    8.     private void FixedUpdate()
    9.     {
    10.         float moveHorizontal = Input.GetAxis("Horizontal");
    11.         float moveVertical = Input.GetAxis("Vertical");
    12.  
    13.         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
    14.         rigidbody.velocity = movement;
    15.      }
    16. }
     

    Attached Files:

  2. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Looks like you need to add a RigidBody component to your spaceship.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    This is discussed on the Space Shooter forum thread. Or is it Roll a Ball? One of those!
     
    Last edited: Jan 8, 2019
    karen_ann and BrandyStarbrite like this.