hi
i am new to unity and just trying out some tutorials in scripting
i am trying to move a sphere on a plane using this script
using UnityEngine;
using System.Collections;
public class playerctrl : MonoBehaviour {
void fixedupdate()
{
float movehorozantal = Input.GetAxis("Horizontal");
float movevertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(movehorozantal , 0.0f , movevertical);
rigidbody.AddForce(movement);
}
}
and its not working. I added this script to the sphere
its not working because the getaxis horizontal and vertical are 0 to 1 and 0 to -1 and u are adding a very low ammount of force to your game object
public float multiplier = 10;
void fixedupdate()
{
float movehorozantal = Input.GetAxis("Horizontal");
float movevertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(movehorozantal * multiplier , 0.0f , movevertical * multiplier);
rigidbody.AddForce(movement);
}
its gonna work but its going to be buggy because this is wrong
Vector3 movement = new Vector3(movehorozantal * multiplier , 0.0f , movevertical * multiplier);