Jump to content

How does Move() work


Rick
 Share

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())
end

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

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

self.entity:SetPosition(pos)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

 Share

×
×
  • Create New...