Hello! I'm attempting to make a two way platform with the love.physics module, and currently the behavior is quite strange. The player will occasionally glitch through the platform, and when the player lands on the platform, the player phases through for a split second then returns to its normal position. I believe this is because I'm switching the platform shape to a trigger once the player hits the platform, not before it, causing this unresponsive behavior. Any ideas on how to improve this design would be great.
Here's the demo and full code:
How to make 2 way platform work properly
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to make 2 way platform work properly
Lua is LÖVE, lua is life
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: How to make 2 way platform work properly
Just forcefully set it to the position or remove all the players vertical velocity during the trigger.
obey
Re: How to make 2 way platform work properly
I tried doing that, like this:
but now the player gets absolutely frozen on the platform and I can't figure out why.
Updated code & demo:
Code: Select all
self.velX, self.velY = self.body:getLinearVelocity()
if self.onPlatform then
self.body:setY(self.platform:getBody():getY() - self.height/2 - 9)
self.body:setLinearVelocity(self.velX, 0)
end
Updated code & demo:
- Attachments
-
- platform.love
- (1.71 KiB) Downloaded 73 times
Lua is LÖVE, lua is life
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests