refrencing question

This forum is currently in read-only mode.
  • Okay if I insert a For condition how do I refrence to that object

  • What exactly do you mean? 'For' condition isn't object

    Do you mean "for each object" loop?

  • Yeah, if you do mean "for each object"

    Then it automatically picks each object one at a time, and any actions referring to that objecttype in that event are automatically executed on the currently picked in that loop

  • Oh I understand now I'm just new to the type of looping in construct sorry if it was to silly to ask.

    One more question please

    What's the best way to make a homing missile

    I've tried storing a variable of the enemy but that didn't work out so well since I can only store strings or numbers in private variables and don't know how to convert that to a family type.

    I thought I'd use the family type to find the closest object of that family and move towards it but I'm having a bit of trouble figuring out how to process objects of a family with a certain name

  • If you do

    + "Family name": Pick closest to: Sprite.X, Sprite.Y
    -> "Family name": - do something -

    no matter how many objects you have in your family, it will always select only one sprite closest to Sprite.XY

    Family works like a group of objects and can share same variables.

    Let say you have 5 different sprites in "Family" and each of them have private variable "Health = 10"

    + Sprite: On collision between Sprite and "Family"
    -> Sprite: Subtract 1 from 'health'

    It will only subtract 1 from collided object.

    other 4 sprites will remain with value 10

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ...and for homing missile it depends. You can give your sprite Bullet behavior and set it to

    + System: Always (every tick)
    -> Sprite_missile: Set angle towards Sprite_target

    edit: couldn't edit last post:/

  • Okay I'm going to try this out now thaks for the help, I'm starting to like Constuct alot now

  • If you want to remember the same target and home on it even when others get closer you could do it like this

    Make missle have a private variable called target, with a default of -1

    For each missle,

    ------if target is equal to -1

    -----------enemyfamily. - pick closest to missle.x,missle.y

    ------------------missle, set 'target' to enemyfamilt.uid

    For each missle

    ------if target is not equal to -1

    ----------enemyfamily, pick by unique id missle('target')

    -------------------missle(with bullet behavior). Set angle toward enemyfamily

    This would make each missle target one enemy and stick with it till the end, though it'll be a bit trickier if you don't want two missles to ever target the same one

  • Thanks for the help it's really appreciated.

    Just for intrest sake how do I refrence a family that has a space in it's name or should I just make a new family with a _ in it's name instead of spaces?

  • don't remember if families warks with spaces in between, i don't even remember if use spaces at all in CC ^^. I'm used to insert _ automatically :)

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