Bullet collision??

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Bullet collision??

Post by jag_e_nummer_ett »

I bet this has been asked a lot of times so I am sorry in that case.

Anyways; bullet collision!
I am struggling hard at getting a good bullet collision code together and I have not yet found someone who has already a good solution I could either steal or port.


Basically the problem:
Bullet goes from A to B through a box. Because the bullet is so fast it misses the box even though it went right through it if you use a normal collision detection code that only checks if the bullet is in the box. I really dont want to just use a loop and try each pixel for collision cause that sounds silly. I want a function that basically gives me the position of the intersection.
Ex:
Image
I've watched this video on AABB Line-box intersection collision code but I can't seem to get it to work that well.

If you wish to try my version go ahead: love file made for love2d 0.9.0
You can move around the points but not the box itself. The collision code is in the box.lua file. Don't mind the package stuff, its kinda irrelevant to this
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Bullet collision??

Post by Azhukar »

Your bullet is not a point. The bullet is actually a vector with length being the velocity.

To get the point of impact you can use line/line intersection.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Bullet collision??

Post by jag_e_nummer_ett »

Azhukar wrote:Your bullet is not a point. The bullet is actually a vector with length being the velocity.

To get the point of impact you can use line/line intersection.
What do you mean my bullet is not a point? In my example .love file I only have two points just to mark the bullet and where its potentially going to be next step.

And you link is quite confusing, I lost track of what they meant after the like 3rd sentence.
Does anyone got a good solution for the collision detection I need?
And Azhukar if your link is a good answer then please explain what they mean with all the Ax B*s Xasgaege whatev
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Bullet collision??

Post by Azhukar »

jag_e_nummer_ett wrote:please explain what they mean with all the Ax B*s Xasgaege whatev
If you intend to do anything at all with such collisions you need to have a basic understanding of (vector) math.

http://www.mathsisfun.com/algebra/vectors.html
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Bullet collision??

Post by jag_e_nummer_ett »

Azhukar wrote:
jag_e_nummer_ett wrote:please explain what they mean with all the Ax B*s Xasgaege whatev
If you intend to do anything at all with such collisions you need to have a basic understanding of (vector) math.

http://www.mathsisfun.com/algebra/vectors.html
Yea you know what f this, I am taking help from another source, not someone like you that just sends a link he got from his google results.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Bullet collision??

Post by Azhukar »

jag_e_nummer_ett wrote:Yea you know what f this, I am taking help from another source, not someone like you that just sends a link he got from his google results.
I can tell you're going to get far in this endeavor. Just because you're 16 doesn't mean you have to act like it, have patience and try to read through it.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Bullet collision??

Post by jag_e_nummer_ett »

Azhukar wrote:
jag_e_nummer_ett wrote:Yea you know what f this, I am taking help from another source, not someone like you that just sends a link he got from his google results.
I can tell you're going to get far in this endeavor. Just because you're 16 doesn't mean you have to act like it, have patience and try to read through it.
I really dislike people like you that just look down on everyone on the internet. Idk what to reply, I'll go try learn about vectors now and hopefully you can help me at that point
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Bullet collision??

Post by Azhukar »

jag_e_nummer_ett wrote:I really dislike people like you that just look down on everyone on the internet. Idk what to reply, I'll go try learn about vectors now and hopefully you can help me at that point
Perhaps you have an inferiority complex? I'm not looking down upon you, merely stated you're acting out emotionally when there was no cause to do so, which was in response to you telling me to fuck off because I didn't code it for you. I provided you with help as to how you can achieve the collision results you want.

Again, I'm not being hostile to you.
User avatar
jag_e_nummer_ett
Citizen
Posts: 52
Joined: Thu May 16, 2013 6:31 pm
Location: Stockholm, Sweden

Re: Bullet collision??

Post by jag_e_nummer_ett »

Azhukar wrote:--snip--
Just a small question, do you prefer using vectors or normal coordinates when using love2d? Or is there no difference?
Azhukar wrote:
jag_e_nummer_ett wrote:I really dislike people like you that just look down on everyone on the internet. Idk what to reply, I'll go try learn about vectors now and hopefully you can help me at that point
Perhaps you have an inferiority complex? I'm not looking down upon you, merely stated you're acting out emotionally when there was no cause to do so, which was in response to you telling me to fuck off because I didn't code it for you. I provided you with help as to how you can achieve the collision results you want.
Ok I've chilled out now
You know what I think you're right idk why but I seem to get in fights all the time. I usually ask for help when I am tired and I bet thats a problem. I apologise and I appreciate that you're still here.
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Bullet collision??

Post by Azhukar »

jag_e_nummer_ett wrote:Just a small question, do you prefer using vectors or normal coordinates when using love2d? Or is there no difference?
Depends on the situation, in this case I think vectors will solve the overshooting issue much more efficiently and easier than continuously checking bullet position "per pixel".

Easiest would be to check whether the bullet vector intersects with any of the 4 rectangle sides, then picking out the point closest to bullet origin (the point from which the bullet vector begins).
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests