Pick object with function

0 favourites
  • 7 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • So I have a whole bunch of platform objects. They all have an instance variable called "trigger" which I change to different values to achieve different things. Right now I do

    -Player: On Colission with platform

    -- Platform.trigger != 0

    -> call function "te_" & platform.trigger

    • On function "te_1"

    -> platform destroy

    It's calling the function perfectly fine, but is deleting every platform instead of the one the player collided with. I know this has something to do with it not passing the platforms id to the function so it knows the specific one to delete. But how do I make it so it knows which one to do?

    Sorry if it's confusing, I'm not the best at explaining things.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you call the function, add a parameter, and set it to the platforms UID. Then in the function, use the "Pick by UID" condition, and set it to the function parameter.

    -Player: On Collision with platform

    -- Platform.trigger != 0

    -> call function "te_" & platform.trigger(Platform.UID)

    • On function "te_1"

    -Pick Platform by UID (function.param(0)

    -> platform destroy

  • zatyka

    I can't test it out right now but that makes perfect sense. Thanks!

  • Um, why do you need the function?

    If you are changing that objects variable you can just compare it, and use that as a trigger.

    No need for all the uid stuff. The object is automatically picked by its variable.

  • newt

    It's not just destroying that I'll be doing. I plan on having a bunch of functions that do different things depending on the trigger variable. I guess I could just have trigger = 1, trigger = 2, ... subevents. In my head this seemed like it would reduce the amount of events I would be using. (I have the free version so I have to watch my events)

  • First of all why can't you destroy the object from the initial event?

    It looks like its picked by the collision.

    Second you would need a sub event to destroy it since you cant pick to destroy from actions.

  • newt

    I don't want to just destroy every platform when the player touches it. Each one can do different things depending on what trigger equals. So most of them will = 0 meaning it wont do anything on contact. 1 means it will delete when touched, 2 would make it disappea for 5 seconds for example. I get now that functions wont save on events and will just over complicate it. I'm just going to make sub events of on collision.

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