Move to an instance of an object

0 favourites
  • 7 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Hello,

    After a long while I am restarting C3 coding again.

    I have an object (say a car) with a moveto behavior, and want an instance of the car to move to an instance of another object.

    The car is named, and the first car instance is selected by having in the event a condition that picks the car instance by name.

    This worked, and I managed to get the first car instance selected after an event, based on the instance's name, but i don't know how to use the MoveTo command to let car move to a first target object instance.

    it seems the only way to do so, is to add another condition to the event that picks the first location by name, which is then "handed" to the moveto ...

    For convenience I don't clone object types but have many named instances in the layout of both cars and named locations they can drive to.

    Is there a way to decouple the selection of the target object instance from the event condition -- so,once an event is received (e.g. start game), then via some lookup a first target instance name is retrieved which is then used to pick the target instance to move to?

    Your help is very much appreciated,

    thank you,

    Dan

  • This sounds very overcomplicated, what do you mean by 'named instances' ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for asking.

    Instances have instance variables defined. One variable is name, which is a string holding a given, unique name on an instance.

    All instances have a unique name predefined.

  • Yeah you add to the condition something to pick the target object. If it also has an instance variable for name then you can use this.

  • I guess that's how it works -- you always have to do the picking as part of the event condition -- you can't pick as part of the action.

    This means that either event conditions must be parameterized -- somehow -- or event conditions must be duplicated to account for all instance identification cases.

    The latter isn't good because it fixes the number of instances assumed existing.

  • Yes that is how Construct works, you pick with conditions and apply actions to picked instances.

  • Don't forget about expression. They can be very efficient by utilizing ternary operator.

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