Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey. I've started learning Unity and I've been following this tutorial pretty much line for line in the code, but this specific line doesn't seem to work at all.

C#
GetComponent<Rigidbody>().AddForce(input * moveSpeed);


This should make the character move, but it doesn't

Here's the entire script

C#
using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {
	public float moveSpeed;

	private Vector3 input;


	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	input = new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
	GetComponent<Rigidbody>().AddForce(input * moveSpeed); 

	}
}


What I have tried:

I've tried messing around with some things but nothing works
Posted
Comments
an0ther1 5-May-16 21:50pm    
This might be a silly question but what are the values for input & moveSpeed?
If either (or both) is zero then you would not expect the character to move at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900