I'll let the code speak for itself but I can't seem to understand why the player doesn't stop when colliding with the ground?
Thanks in advance!
Why is this collision not working?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Why is this collision not working?
- Attachments
-
- RCC.zip
- (6.2 KiB) Downloaded 119 times
Re: Why is this collision not working?
In the players update replace this:
by this:
If there are several nodes and the player collides with node 1 but not with node 2, then your code sets the onGround to false (because node 2 is checked after node 1). But you want to detect a collision if the player collides with any node.
Code: Select all
for i,v in ipairs(node) do
if CheckCollision(Player.x,Player.y,Player.width,Player.height, v.x,v.y,2,1) then
Player.onGround = true
else
Player.onGround = false
end
end
Code: Select all
Player.onGround = false
for i,v in ipairs(node) do
if CheckCollision(Player.x,Player.y,Player.width,Player.height, v.x,v.y,2,1) then
Player.onGround = true
end
end
Check out my blog on gamedev
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests