|
Here is my movement code for the player:
(WARNING: PSEUDO CODE AHEAD) My problem is when the player attempts to move outside of the boundaries, they do for a split second, THEN the code forces them back. This turns into a player constantly twitching if they constantly try to cross the boundary. What I want, is to grab the player's position from what would happen if they attempted to cross. This is what I mean by what I want:
Now I guess that I could make this happen by having a clone box off screen move first, as in:
But I think that would eat up too much resources, and that there is a better solution. Or am I wrong?
(comments are locked)
|
The link Lipis gave in comment indeed explains the So by making sure we never set the value outside the allowed range we won't get jittering. Thanks, but could I also have an explanation?
Mar 15 '10 at 12:55 AM
The BOOM
@Sethbeastalan check the example here: http://unity3d.com/support/documentation/ScriptReference/Mathf.Clamp.html do you need more?
Mar 15 '10 at 01:18 AM
Lipis
I can't vote this up, (yet), but I just wanted to add that the last 4 lines of the script above work amazingly well.
Dec 29 '12 at 12:51 AM
samsmithnz
(comments are locked)
|
