Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Well, fuck me.
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#4
RE: Well, fuck me.

EDIT: BeeKayK beat me to it, but, here's some explanations nevertheless.

About the functions:
When scripting/programming, it's a good practice to give your functions descriptive names (descriptive in the sense that they tell you what the function does) - not only it will help other people understand your code when asking questions on forums, or when you release a CS/FC when other people might try to learn from your source code, but it can even help you, especially if you decide to put the project on hold and maybe work on something else for a while - when you come back to the projject, say, a few weeks later, descriptive names will help you get back on track more quickly.
But, it's your choice.

About the "alState":
The alState parameter is an input variable to this callback (which you've allready hooked up):
void umadbro(string &in asParent, string &in asChild, int alState)

When a collision is detected, umadbro() is called. Now, the value of alState is passed in by the engine when a collision is detected, and it has the following meaning:
  • 1 --> means that the two entities just started to intersect (enter event)
  • -1 --> means that the two entities just stopped intersecting (leave event)
You can check the parameter to see which event has occurred. So, you already have all that you need, and the last param to the hookup method, 0, means that the umadbro callback should be called on both (enter) and (leave). So, that's OK too.
What BeeKayK is suggesting is to simply check the value of that parameter, instead of using
GetEntitiesCollide(). You don't have to add a new entity collide callback. Edit: Oh, you want to check for collisions with "area_2" - then yes, add a new callback!

P.S. But make sure that the fourth parameter is false( == don't delete callback on first collision detected):
PHP Code: (Select All)
AddEntityCollideCallback("Player""area_2""callback_name"false0); 

This is so that every enter/leave event can be detected; one way to connect it back to the umadbro() callback is to simply have an indicator variable set inside the callback_name() callback, that will record if the player is inside area_2 or not, and then check that variable from inside the umadbro() function.

PHP Code: (Select All)
bool isPlayerInArea2 false;
void callback_name(string &in asParentstring &in asChildint alState)
{
        
isPlayerInArea2 = (alState == 1);  // will be true if they intersect, false if not


Then you can just go:
PHP Code: (Select All)
if (isPlayerInArea2)
{
    
//whatever
}
else
{
    
//whatever else

(This post was last modified: 01-20-2013, 11:04 PM by TheGreatCthulhu.)
01-20-2013, 10:46 PM
Find


Messages In This Thread



Users browsing this thread: 1 Guest(s)