rigidbody.velocity

Hi guys!
Have a little problem - can’t move my object (your tutorial about space shooter)

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour 
{

	public float speed;
	void FixedUpdate ()
	{
		float moveHor = Input.GetAxis("Horizontal");
		float moveVer = Input.GetAxis("Vertical");

	    Rigidbody rb = GetComponent<Rigidbody>();

		Vector3 move = new Vector3 (moveHor, 0.0f, moveVer);
		velocity = move * speed;
	}
}

rb.velocity = move * speed;
Also I’d highly recommend to store reference to rigidbody only once instead of every time on FixedUpdate, you can see and example of how to do it THERE.

GetAxis is a float func, between 0f and 1f.

U must have a higher force point, or use;

gameObject.GetComponent<Rigidbody>().AddForce(new Vector3
(moveHor*speed*Time.deltaTime,0.0f,moveVer*speed*Time.deltaTime);

or yes, use DotA’s solution :slight_smile:

see this unity Scripting assist