Collision detection perfection

You must understand the Game Editor concepts, before post here.

Collision detection perfection

Postby ikarus » Sat Aug 13, 2011 7:30 pm

A game I'm working on requires a lot of bouncing sprites, the arena is just a vector image I made with a width of 4 pixels. I noticed that as the speed of the sprites increases, they start flying out of the arena, or if the player hits a pretty acute angle they'll fly out sometimes too.

Does anybody have any good rules of hand when it comes to collision detection? Should I just forgo a physical response and just change the direction of each actor hitting the arena?

Thanks^^
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Collision detection perfection

Postby skydereign » Sat Aug 13, 2011 10:16 pm

At that point you'll probably need to create your own collision detection system. You can use CollisionFree and possible getactor for this. But if you are using collision events and PhysicalResponse, you have to have the max speed be less then the width of the tile. That way no matter what speed they come at, the actor can never pass half of the tile. This should also apply to acute angles, just make sure to cap the bounce velocities in the collision event. If you are looking for alternatives to collision events, there are several users that posted their own perfect collision demos.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision detection perfection

Postby Jagmaster » Sun Aug 14, 2011 2:33 pm

I have a question regarding Collision free. How do you tell an actor to do an event if it is not colliding with a certain actor? When I try, it wants to check collision with every actor. Is there any variable or argument that can be placed in between the parentheses of Collfree in order to do this?
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

Re: Collision detection perfection

Postby ikarus » Sun Aug 14, 2011 11:09 pm

Perfect answer! You've given me a lot to to think about, I'll start messing with the dimensions and speeds. Kinda curious about jagmaster's question though lol
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Collision detection perfection

Postby Game A Gogo » Mon Aug 15, 2011 4:12 am

Jagmaster wrote:Is there any variable or argument that can be placed in between the parentheses of Collfree in order to do this?

Unfortunately no. You could use GetAllAcotrsInCollision (or something) so it returns all actor colliding with the current one, but then you can't use the X and Y offset trick. I suggest maybe creating an almost invisible dummy (Most likely behind everything, even the back ground, collision still happens if actors are overlapped). Then you can set the position of the dummy collision and use the get all actors in collision. If you need help with the function, simply go into Help -> Documentation -> Scripting -> Script Reference then you can search for the function
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Collision detection perfection

Postby ikarus » Mon Aug 15, 2011 5:23 pm

I'm on linux and I don't see the documentation option in the help menu? Is the linux version using an older ui? by the way has anyone ever made an effort to create a wiki for game editor?
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Collision detection perfection

Postby Game A Gogo » Mon Aug 15, 2011 9:13 pm

GE wiki does or did exist... Rarely used. Also documentation should be in your GE folder GameEditor/Docs/index.html
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Collision detection perfection

Postby skydereign » Tue Aug 16, 2011 5:41 am

I've been trying to work on the wiki, and in a month when I'm done working with Omni-arts I'll have the time to continue making it worth looking at.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision detection perfection

Postby ikarus » Sun Aug 21, 2011 4:31 am

Just curious, anyone have a good technique for finding the point of the collision?
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Collision detection perfection

Postby ikarus » Sun Aug 21, 2011 8:30 am

Nevermind, I found out! Woooooo!

Code: Select all
int xx;
int yy;
int i;
int xvol = xvelocity;
int yvol = yvelocity;

while(i < 1000){
    xx += xvol;
    yy += yvol;
    if(xx >= width*0.5 || xx <= width*0.5*-1){
        xx += -10*(xvol*xvol)/abs(xvol)/xvol;
        i = 1000;
    }
    if(yy >= height*0.5 || yy <= height*0.5*-1){
        yy += -10*(yvol*yvol)/abs(yvol)/yvol;
        i = 1000;
    }
    i++;
}


To get the exact position just add tha actor's real cordinates.
Code: Select all
xx += x;
yy += y;

The "xx += -10*(xvol*xvol)/abs(xvol)/xvol;" and "yy += -10*(yvol*yvol)/abs(yvol)/yvol;" aren't needed, that's just something I used to find the coordinates to create my particles. I set the position back 10 pixels from the hit cause the thing it was hitting was messing with their look lol. Just included them to show how you may want to fine tune it using some nice math. I have the loop end at 1000 because I found that sometimes ge bugs and the loop never ends, not very often, so I made a failsafe. Plus I doubt you'll ever need a collision point that'll be beyond that. But if you do, just change the limits. Don't know how fast this is, but it works fine for me :D

Enjoy ^-^
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Collision detection perfection

Postby ikarus » Mon Aug 22, 2011 4:42 am

Actually I should mention that it's not 100% perfect since it uses the velocities, so if something hits the head of the character while your moving right then it'll think the collision is directly to the right. I could think of a way to do it perfect but that would probably mess with the colliding actors x/y and width and height and won't work for large actors that say make the level like tiles. Got's me wondering how about doing perfect collision points though
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron