- Home /
Sprint script help, I keep through the floor
Okay, so i made a new script to go along side the Fps controller + motor script, just i need to find a way to only sprint on the x or z axis, because if i look up or down while sprinting, i either go through the floor or fly into the air, I've tried changing the 'forward' to x but that just makes me sprint one way, help? here is my code :
enter code here#pragma strict
var speed : float = 0.1;
var cooldown : float = 2;
function LateUpdate ()
{
if (cooldown > 1)
if (Input.GetKey("q") )
{
this.transform.position += this.transform.forward;
cooldown -= Time.deltaTime * 2;
}
if (cooldown < 2)
{
cooldown += Time.deltaTime / 4;
}
}
I just need a way to only sprint on a flat axis:(
You should only play with actual Controller's speed values. Transform forward will make you go in the direction you face.
Of course you can, it's relatively easy: https://www.google.com.tr/search?client=opera&q=unity3d+reaching+other+scripts&sourceid=opera&ie=UTF-8&oe=UTF-8
Look at the player's control script. The bit that deals with mouse input vertical? Take out the code that makes it control player rotation and make it control the Camera ins$$anonymous$$d.
Your answer

Follow this Question
Related Questions
java NullReferenceException with 3 button game, works for 1 key but not the other 2. 0 Answers
How to make a simple AI escape script? 2 Answers
Object moving on its own 0 Answers
Unity not recognizing Instantiate? JavaScript 1 Answer
Stamina script system 0 Answers