Collision in Script editor

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

Collision in Script editor

Postby Rufus 01 » Tue Oct 16, 2007 3:02 pm

Hey is it possible to make a script in the script editor for Collison events?
I meen:
Code: Select all
if ("actor1" collide by "actor2") { //my code }


Befor everyone is saying no its not possible with the key down event it works.
For example:
Code: Select all
char * key = GetKeyState()
if (key[KEY_LEFT]) { //my code }


but I need all that with 2 actors...
I want that because it would be esier to make a script where I get an statement when 2 actors collide at the same time by one other actor.
For example:
Code: Select all
if ("actor1" && "actor2"  collide by   "actor3") { //my code }


Sorry for my bad englisch :wink:
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score

Re: Collision in Script editor

Postby DilloDude » Tue Oct 16, 2007 11:25 pm

I'm pretty sure you can't do that :( the closest thing might be the CollisionFree function, whcih isn't very useful... :cry: But you might be able to work around, if your actors are simple shapes, or you don't care whether the 'collision' is pixel-perfect or not. IE you might just be able to check distance, and see if it's small enough, or perhaps x and y coordinates to get a more rectangular shape.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Collision in Script editor

Postby Rufus 01 » Wed Oct 17, 2007 3:16 pm

hmm :?
the collisonFree function I used by myself but don't know how it works...
and the distance is to complicated I think for want I want it... :|
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score

Re: Collision in Script editor

Postby DilloDude » Thu Oct 18, 2007 2:49 am

What is the exact situation you're using?
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Collision in Script editor

Postby Rufus 01 » Thu Oct 18, 2007 1:47 pm

I want to get one score point only when 2 actors at the same time collide with the 3rd.
I could make it also with 2 variables and a script that test it 2 variables have state 1 or any other thing.
But I want to do all that without any variables.. :wink:
Because so I could have all of that little thing in one script and musn't change in the script windows of every CollisonEvent...
I hope u understand me :mrgreen:
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score

Re: Collision in Script editor

Postby DilloDude » Thu Oct 18, 2007 10:39 pm

What shape are the actors? and are they cloned, or is there only one of each?
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Collision in Script editor

Postby Rufus 01 » Fri Oct 19, 2007 2:47 pm

everyone is a own normal actor.
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score

Re: Collision in Script editor

Postby DilloDude » Sat Oct 20, 2007 5:05 am

One thing you can use is the getAllActorsInCollision function (why didn't I think of that before). So it might be something like:
Code: Select all
int n;
Actor *actors = getAllActorsInCollission("Event Actor", &n);
if (actors)
{
    char found;
    int i;
    for(i = 0; i < n; i++)
    {
        if (strcmp(actors[i].name, "actor1") == 0);
        {
            found |= 1;
        }
        else if (strcmp(actors[i].name, "actor2") == 0);
        {
            found |= 2;
        }

        if (found == 3)
        {
            //Your Code here
            break;
        }
    }
}
on actor3's draw actor. You might want to modify that somewhat.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Collision in Script editor

Postby Rufus 01 » Mon Oct 22, 2007 7:32 pm

Thanks I will test it now in GE :)
Was geht'n? =D
Rufus 01
 
Posts: 73
Joined: Sun Aug 27, 2006 9:51 am
Location: Lisbon, Portugal
Score: 3 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest