Hi. Super new to Love, Lua, etc. Trying to make a first game and realized I had to implement collision. Looked around a bit and decided to go for a simple AABB implementation.
However, depending on the angle that my rocket hits a star, it will "slide" along the surface of the star very shakily before bouncing back the opposite direction.
edit: fixed
Collision Behavior
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Collision Behavior
Last edited by owlkatraz on Thu Dec 25, 2014 7:16 am, edited 2 times in total.
Re: Collision Behavior
Your rocket collides with more than 1 star simultaneously, each time negating its angle.
Write "break" after line 76. That means after you detect a collision and correct it, you call "break" and stop checking for more collisions by escaping the for loop.
Write "break" after line 76. That means after you detect a collision and correct it, you call "break" and stop checking for more collisions by escaping the for loop.
Code: Select all
for i, curStar in ipairs(starList) do
if(CheckCollision(rocket.minx, rocket.miny, rocket.maxx, rocket.maxy, curStar.x, curStar.y, curStar.x + curStar.width, curStar.y + curStar.height)) then
CorrectCollision(rocket.minx, rocket.miny, rocket.maxx, rocket.maxy, curStar.x, curStar.y, curStar.x + curStar.width, curStar.y + curStar.height)
break
end
end
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Collision Behavior
If you want simple AABB collision, kikito's Bump library is really good for that.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests