Results 1 to 5 of 5

Thread: OnCollisionEnd() - One final quick question!

  1. #1
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default OnCollisionEnd() - One final quick question!

    Each Entity can have its own OnCollision() function which is called when a collision takes place.

    Is there any way to detect when a collision has stopped occuring?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,555

    Default

    If you check the reference for SetCollisionListenCategory, you'll see I have a cryptic message of "(Don't worry about state for now, will add more later..)".

    This state is a number that tells you more about the collision:

    0 = started colliding
    1 = still colliding
    2 = stopped colliding

    So that should do what you want. Warning, not tested.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default

    Quote Originally Posted by Seth View Post
    If you check the reference for SetCollisionListenCategory, you'll see I have a cryptic message of "(Don't worry about state for now, will add more later..)".

    This state is a number that tells you more about the collision:

    0 = started colliding
    1 = still colliding
    2 = stopped colliding
    Funnily enough I did recently check the reference for SetCollisionListenCategory, as my player's collision is based on the TreeWorld example and I was intrigued by the (Don't worry about state for now, will add more later..) comment... however...

    Warning, not tested.
    Unfortunately it's been tested now, and it doesn't appear to work

    here's my function, which I have applied to an entity:

    Code:
    function OnCollision(vPosition, vVelocity, vNormal, depth, materialID, entity, state)
    
    //LETS TEST TO SEE WHAT STATES 
    //ARE BEING PROCESSED
    
    LogMsg(state)
    
    	if (state<2) then
    			g_overitem = true;
    			GetPlayer:Data():Set("overitem", this:Data():Get("overtext"));
    			GetPlayer:RunFunction("UpdateGUI");
    
    	else
    
    		g_overitem = false;
    		GetPlayer:Data():Set("overitem", " ");
    		GetPlayer:RunFunction("UpdateGUI");
    		
    	end
    
    end

    There is never a 2 showing in the console. States 0 and 1 appear to be functioning correctly, but not 2

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    4,555

    Default

    Hmm, thanks for letting me know, I'll check out why state's ending a collision aren't being sent...

    In any case, you will continue to receive collide events while a collision is taking place each frame, so another route would be to mark something when a collision begins, then notice when you stopped getting collisions.

    Like, in the entity's Update, if a collision had started, you could make sure a var (m_bGotCollision for instance, name doesn't matter) is true at the top, and set it to false at the bottom.. and set it to true in the collision event.

    This way you'd notice when the collisions had stopped and could act on that.
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default

    Hey Seth

    I'm not really following how that would work, as then the variable would *always* be false at the bottom of the update step, and *always* true at the top?

    Anyhow, I have approached the problem from a slightly different angle and kind of lucked into a solution that gets the result I want without actually needing to check for the collision ending.

    Thanks again for all your help, will get the first phase of the game finished over the weekend and send you a link so you can have a play.

    cheers!

Similar Threads

  1. Beginner quick questions
    By bullno1 in forum Novashell Game Creation System
    Replies: 2
    Last Post: 08-02-2008, 02:09 PM
  2. the final boss
    By zol in forum Dink Smallwood HD
    Replies: 1
    Last Post: 12-08-2006, 11:58 AM
  3. Yo, Seth quick question man.
    By in forum RTsoft Tavern
    Replies: 3
    Last Post: 07-14-2004, 03:53 PM
  4. Quick feedback for why I won't be buying
    By in forum Other RTsoft Games
    Replies: 1
    Last Post: 12-13-2003, 05:01 AM
  5. Your a quick one
    By -WC- in forum RTsoft Tavern
    Replies: 4
    Last Post: 06-19-2003, 08:37 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •