• How to set the player's next position in step?
    4 replies, posted
I've been doing some freelance work for Garry's Mod and someone asked me to create a node-based track system so the players would stay in their lane. I've decided that to get where the player is in the race by lerping the player's position between 2 nodes however, the issue with just adding to a lerp is that SetPos() has a teleport-like feeling and I also want to be able to change the velocity using SetVelocity also to calculate UPS (Units Per Second) using velocity. So I just need a way to kinda pull the player to the center of the track instead of just teleporting the player and having them use a running animation. [I]Due of the limitations of mobile I cannot show any code or images of the node system however, I will do so when I get home to give you a better understanding of the track system[/I]
I think this is what youre looking for: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LerpVector]Global.LerpVector[/url]
Again, I'm already using a lerp between nodes
You said you wanted to lerp but not to set the position directly. But i didnt hear that you used LerpVector. Sorry :saddowns: im trying to be useful
[lua]function GM:Move(pl, mv) local curpos = mv:GetOrigin() local target = LerpVector(delta, pos1, pos2) -- fill in here local dir = target - curpos local dist = dir:Length() mv:SetVelocity(FrameTime() * dir * math.Clamp(dist, 10, 500)) -- play with the two numbers end[/lua] This needs to be shared to be smooth.
Sorry, you need to Log In to post a reply to this thread.