Jump to content

How does Move() work

Recommended Posts

What is Move() doing behind the scenes? I was using it to move left/right but now I need to rotate the player but still move on the x plane only so can't use Move() as it's relative and not what I need. So I figured I'd use SetPosition() and just add to the x position but it moves super fast now where with Move() it was smooth. So I assume Move() was doing something to smooth this movement that I now need to do.



if self.window:KeyDown(Key.A) then
x = ((1 * self.moveSpeed) * Time:GetSpeed())

if self.window:KeyDown(Key.D) then 
x = ((-1 * self.moveSpeed) * Time:GetSpeed())

-- move the player
--self.entity:Move(x, 0, 0)
local pos = self.entity:GetPosition(true)
pos.x = pos.x + x


Share this post

Link to post

Are you using that code in UpdatePhysics ? If you use SetPosition() in UpdateWorld it will be smooth.

If it is too fast you can decrease your self.moveSpeed parameter.

Share this post

Link to post

Well, the idea I'm looking for is with that speed value it works great for Move() but not for SetPosition() but wondering why exactly. The above code is called in the same spot.


@Einlander Nothing changes if I do that. It's still super fast movement. To the point where it looks like he's teleporting but you can faintly see trails so you know he was in another spots and is just moving really fast.

Share this post

Link to post

I have the same rotate problem, except my player either does not rotate at all or "strafes" to the side instead of rotating on the spot. My code is in the UpdatePhysics loop.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...