Any tricks with activation regions?

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

Any tricks with activation regions?

Postby ikarus » Sun Aug 28, 2011 1:13 am

I've realized I'm having a lot of problems with activation regions, for instance, I've noticed that some actors when set to create at startup stay there and are in their same state when the view returns. I have the view going into another region which had the main program menu, but if the player wants to play again, I notice the main actor is still where they were before??? Anyone else have issues like this and have some tricks or workarounds?
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Any tricks with activation regions?

Postby skydereign » Sun Aug 28, 2011 1:57 am

The rules of activation regions are any actors within a region that is colliding with the view, exist. When you leave, the actors are destroyed. But, when you come back to the region, they are all recreated (resetting actor variables as they start fresh). You can however destroy actors permanently, but you have to destroy them with the DestroyActor function (otherwise they come back). This does not apply to any actors you used CreateActor to create, as those are always destroyed when you leave the region.

So usually what people do, is create a player in each region, or what I prefer, create a player spawner. On its CreateActor, you create the player. This will keep the player spawning at the right place when you enter the region. The problem though that you described, doesn't seem to make sense, but this method will still fix it, as you are using an actor created from CreateActor.

One thing that may look like actors keeping their states or positions is if they are altered by global variables. For instance a health bar using an hp variable would appear to have not been destroyed as it keeps the same hp value. Anyway, hope this helps.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Any tricks with activation regions?

Postby ikarus » Sun Aug 28, 2011 2:06 am

I did what you sugested and yep, that works. But I swear to god it's true. The only global it uses is one the tells it what animation to have as that's a big part of the game. I'd leave the region and bam when I returned it was where I had moved it last, not where I set it to be in the editor. Weird...

I'll probably from now on only use act. regions for tile areas and static actors then have spawn actors for everything else like you suggest
>>>>>>>>>>>>>>>>>>>>> http://www.code1011.com <<<<<<<<<<<<<<<<<<<<<<<
ikarus
 
Posts: 143
Joined: Fri Aug 12, 2011 3:06 am
Score: 11 Give a positive score

Re: Any tricks with activation regions?

Postby skydereign » Sun Aug 28, 2011 2:13 am

Yeah, I know what you mean. I avoided activation regions for a while, as they just wouldn't cooperate. After using gE a lot, you'll automatically bypass a lot of these problems, such as your export/editor problems.
User avatar
skydereign
 
Posts: 3513
Joined: Mon Jul 28, 2008 8:29 am
Score: 588 Give a positive score

Re: Any tricks with activation regions?

Postby Hblade » Tue May 08, 2012 4:28 pm

You could create a VirtualRegion, something that acts amost the same way an activation region does, but you can control where its at. like this:
Code: Select all
int regId[10000];

void virtualRegion(char *effectedActor, int regionID, int X, int Y, int Width, int Height)
{
    Actor*actor=getclone(effectedActor);
    regId[regionID]=1;
    if(actor->x>X&&actor->y<X+Width&&actor->y>Y&&actor->y<Y+Height)
    {
        VisibilityState(effectedActor, ENABLE);
    }
    else
    {
        VisibilityState(effectedActor, DISABLE);
    }
}



Example usage:
Code: Select all
virtualRegion("coins", 0, 500, 25, 64, 64);

This creates a virtual activation region at X: 500 and Y: 25, with a width and height of 64. This effects the actor called "coins", meaning if the coins actor isn't inbetween 500 - 564X and 25-89Y, it will not be drawn.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 180 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest