I have been searching for an answer to this but haven't found one good enough to help me figure this out. My code is the same as in the Space Shooter tutorial. link:(https://unity3d.com/earn/tutorials/projects/space-shooter/moving-the-player?playlist=17147) at the 6:39 mark his code looks like in this paint screenshot i took: http://imgur.com/a/oltkX
My code is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement;
}
}
So there is a different "using" part at top but other than that I don't get why my velocity is highlighted wrong. in: rigidbody.velocity = movement;
In the monoDevelope I get the word velocity highlighted in red and hoverover it to get error CS0117 UnityEngine.Component doesnot contain a definition for velocity.
I am a noob so I don't what what that means
In Unity program I get error :
Assets/Scripts/PlayerController.cs(15,13): 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?
Any help for this noob would probably be a great learning experience for me as I don't know much about coding and have just started out, thanks community!
↧