action to object with value on collision?

0 favourites
From the Asset Store
Alot of High Quality Items sound effects for your game!
  • Try this:

    I'm not clear on what flag is supposed to be set where but you can change that condition to your likings.

    EDIT:

    You're actually just having issues with colliding with the same object. See this post's example capx. Construct is not very limiting at all but it does take some time to get used to how the picker works:

    https://www.scirra.com/forum/collision-between-instances-of-the-same-object_p686645?#p686645

    Good Luck!

  • I think what he is trying to do is the following:

    Have a sprite instance with flag 1 and all other instances with flag 0. When flag1 sprite collides with flag0 sprites, flag0 sprites should have a set opacity to 25.

    Meanwhile, it has to be the same exact object not a clone of it and you need to only set the opacity to the sprites that are colliding not the ones that aren't colliding with flag1 sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok! Thanks Vallar for clarifying that.

    seawall This does what has been described:

    EDIT: Added comments

  • I presume you dont have acces to famelies.

    Allow me to offer you 2 warnings.

    1/ I am not an expert.

    2/ I am pretty sure that there is no easy solution.

    Two more general things.

    On Collision is a trigger. In your Cap none of the 'sprites' is moving. So its kinda useless to use On Collision. The trigger keeps firing.

    Because the trigger keeps firing, your Cap is in a state of an endless loop. You should be more carefull with that.

    Now. Your problem. Why is it not that easy?

    Well, when using 'on collision' condition on all those 'sprites' a big list of sprites is returned as a result in the Selected Object List (official term, wich i call 'the picklist'). 15 in your case.

    On top, you want to compare them in pairs.

    Is one's flag 0 and the other one's flag 1, then do this(), if they overlap.

    This Cap is one way to do it. The ListObject gives inside on whats happening. Lists are awsome debugging helpers.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74RTkzNWVRS0llVXM

    You will see 'pick all' conditions.

    Why?

    The conditions before those 'pick all' conditions narrowed down The Picklist.

    The 'sprite' that needed to be tested was not any more in The Picklist.

    Therfore, enlarge The Picklist was needed.

  • Ok! Thanks Vallar for clarifying that.

    seawall This does what has been described:

    EDIT: Added comments

    this metod almost works, only problem its not work on start or block not moving, changing to overlaping not help.

    i need make it work when blocks not moving.

  • I presume you dont have acces to famelies.

    Allow me to offer you 2 warnings.

    1/ I am not an expert.

    2/ I am pretty sure that there is no easy solution.

    Two more general things.

    On Collision is a trigger. In your Cap none of the 'sprites' is moving. So its kinda useless to use On Collision. The trigger keeps firing.

    Because the trigger keeps firing, your Cap is in a state of an endless loop. You should be more carefull with that.

    Now. Your problem. Why is it not that easy?

    Well, when using 'on collision' condition on all those 'sprites' a big list of sprites is returned as a result in the Selected Object List (official term, wich i call 'the picklist'). 15 in your case.

    On top, you want to compare them in pairs.

    Is one's flag 0 and the other one's flag 1, then do this(), if they overlap.

    This Cap is one way to do it. The ListObject gives inside on whats happening. Lists are awsome debugging helpers.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74RTkzNWVRS0llVXM

    You will see 'pick all' conditions.

    Why?

    The conditions before those 'pick all' conditions narrowed down The Picklist.

    The 'sprite' that needed to be tested was not any more in The Picklist.

    Therfore, enlarge The Picklist was needed.

    this metod only works on start, if i try change every coolision or every x second to update collision there will be big perfomance problem like 1 fps on 6 core 3gz CPU.

  • Alright I was fiddling with this more and the overlap condition in construct just reports ALL sprites that are overlapping and it's difficult to compare two objects of the same type with that. I don't see a reason why instead of using an instance variable, you just create a separate object, Doing this allows more power anyways and simplifies all that code I posted earlier to just this:

    Sprite3 would be your "Flag=1" objects. Where the Sprite would be your "Flag=0" objects. Which gives this result:

    This greatly simplifies your task and I believe produces what you want. If you ever needed to change an object your can just spawn a new one and delete the old one in it's place if needed. Instance variables can also be added to the https://www.scirra.com/manual/142/families if you have access to that.

  • Collisions is a total differend story. You provide a CAP with not 1 collision is happening. Then you complain that the solution only works for your CAP.

    So, here is a CAP that understands collisions.

    https://

    drive.google.com/open?id=0B1SSuCVV8v74WTJaNWVSdUtXeWc

    There is a Framedrop 4sure. But not because of de few events. Press the key to dissable the events.

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