destroy an object on collision if key pressed...

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi guys . I need some help again with the events.

    I would like to destroy an object on collision if a key pressed.

    I mean a copy of an object.

    For example:

    player:on collision with other object/do nothing,go to sub event

    -sub event key pressed/destroy other object

    But for some reason I can't use "on collision" and "key pressed" in the same event.If "on collision" has been used I can use only "key down".

    Why is that?

    I have tried to use variables,but in that case all the objects destroy

    Like this:

    (global variable created collision = 0)

    player:on collision with other object/collision = 1

    collision = 1/do nothing go to sub event

    -sub event key pressed/destroy other object

    In this case all the objects destroy,not only collided object because the second event don't know I have collided,it knows only collision = 1.

    I know I can store UID in a variable but how can I use that in event?

    I can use it like this:

    player:on collision with other object/variable = object.UID

    But there is no event to use it like this:

    destroy object:variable = object.UID

    spawn other object:variable = object.UID

    Anybody could help me please?

    How do I destroy a copy of an object on collision if key pressed?

    How do I reference to object.UID in event?

    Thanks.

  • Hi ddabrahim,

    You won't be able to add the 'On collision with' & 'On key pressed' conditions into the same event. This is because they are both trigger events (learn about events here).

    Each will only fire on the appropriate trigger, and two triggers can never fire simultaneously. However, you could try changing your 'On collision' trigger, to 'Is overlapping' instead!

    Hope that helps.

  • How about adding a booleen variable to go true on key pressed and false otherwise and then require it to be true for the on collision event?

  • changing your 'On collision' trigger, to 'Is overlapping' instead!

    Hope that helps. agreeded.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Blacksmith "is overlapping" works,but I thought it can be done somehow on collision also.

    amishstripclub,variables don't help in my case,because I'm using copies of objects.So if I set a variable true or 1 or 2 or whatever on collision or key press,it knows only the value has changed and what to do if it changed.But not recognise which object need to be destroyed .Destroy all copy of the object because of the same name.

    Now this is my second problem,if I make copies of objects,how to recognise which is which , which to destroy,which to spawn,which to move.if I pick UID and store it in variables seems don't work. <img src="smileys/smiley11.gif" border="0" align="middle" />

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