Jump to content

Recommended Posts

Posted

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)

Posted

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.

Stop toying and make games

Posted

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.

  • 2 months later...
Posted

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.

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.

×
×
  • Create New...