First I want to say Hello to everyone, I'm brand new to the forums and have been playing around with AC for few weeks now. Great engine and thank you for your hard work on it.
My question is when using the first person control, how do I restrict the player from moving in any direction while jumping? Example would be, if I jump forward I am still able to move left, right, or back while jumping. I want to restrict the player to only jump in the direction he or she is facing making it more realistic in a way. I did some searching around in the forums and wasn't able to find any kind of answer to this. Also did some google searching and didn't find anything there either. Any help would be very appreciated.
Thanks,
- Rick
Comments
It should be possible to do this by running a custom script in your scene that basically locks player movement whenever they're jumping. In a new C# script, replace the default Update function with this:
private void Update ()
{
if (AC.KickStarter.player != null)
{
bool restrictMovement = AC.KickStarter.player.isJumping;
AC.KickStarter.playerInput.SetUpLock (restrictMovement);
AC.KickStarter.playerInput.SetLeftLock (restrictMovement);
AC.KickStarter.playerInput.SetRightLock (restrictMovement);
AC.KickStarter.playerInput.SetDownLock (restrictMovement);
}
}
Then attach it to a GameObject in your scene. The hyperlinks will take you to the relevant pages in the Scripting Guide to show you what's being done.
Thanks so much for a quick response. After a little bit of fiddling with the code and removing
AC.KickStarter.playerInput.SetUpLock (restrictMovement);
I was able to get the desired effect.
Thanks so much!
- Rick