How do I inspect collided with object variable before action

0 favourites
  • 10 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I need to perform an action when an Enemy collides with another enemy only if the other enemy has a property set to 1.

    if I was writing code it would be something like:

    void OnCollisionWith<Enemy>(Enemy enemy){
      if(enemy.Property ==  true){
          doSomething();
    }
    
    return;
    }[/code:1nuyhz1j]
    
    does that make sense?
    
    something like this...
    [img="http://s19.postimg.org/853e28aw3/enemy.png"]
  • Just add another condition. AND is the default, unless you make an or or else block.

  • If the event isn't true if the first instance has the variable set to 1, a "system pick nth instance" condition before the check should work for this..

  • additing another condition inspects the value of the colliding enemy... I need to inspect the collided with enemy

    <-- this no workie!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • LittleStain - I don't see how this can work.

  • The framework is smart enough when using different object types, but not when using same object types...

    If I wrote this - it would work properly. I connected the same instances...

    But this is how it behaves when using the same types..

    I need this:

    Does this illustrate my challenge a bit better?

  • Hmm sounds challenging

  • Like I said, to differentiate between the two colliding objects you use subevents with the "system pick nth instance"-condition..

    Like the manual says:

    Pick Nth instance

    Pick the instance at a given place in the internal list of picked objects. This is most useful used in sub-events to act on separate instances. For example, in a "Sprite collided with Sprite" event, Pick 0th instance and Pick 1st instance can be used to act on each instance involved in the collision separately.

  • I've not made use of this before but I think I will be doing now, looks useful. Seems nth instance 1 works for this scenario.

  • You're trying to make an event for an object colliding with the same type.

    This is not super intuitive because of the way events work to narrow down objects within a type or family.

    Try this:

    Make a family called "Enemies" and put ONLY THAT enemy in it. Now make your event

    Enemy on collision with Enemies

    and

    Enemies explode = 1

    ==> Enemies.destroy

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)