How do I set an instance of same object to another iid/uid

0 favourites
  • 9 posts
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • Hey there,

    iam currently in a little hassle with this one:

    I have two instances of the same type in my scene (its an endless runner) and now i want to reposition one object behind the other if theyre outside the screen. So far so good. But how do i place my object (iid 0) behind the same instance object (iid 1) ?

    Could not find out currently how to set this up...

    Thanks for your suggestion!

  • Congrats2u

    Usual method for doing things where you need to pick two of the same type is to add a Family with just that object type in it.

    For example, if you have an object type called Player, create a family called Family_Player with Player as a member.

    So, your event could maybe be something like this:

    Player is on screen (inverted)
    Pick Family_Player where Family_Player.X > Player.X
    	-> Set Player.X to Family_Player.X - Player.Width
    [/code:2rq06c5u]
  • endless runner & reposition one object behind the other if theyre outside the screen

    Endless means that those objects start outside the screen (on 1 side) and move off screen (on the other side) ?

    Do they flip each pass ? Or is it a 1 time operation ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 99Instances2Go

    Thats right, they move from right to left, and if they leave the screen they will be repositionated on their old/start position.

    The problem is: If i set it up like: if sprite is - 1024 it can happen that there is a small lag or delay and i get a gap between my background sprites. I got four background sprites layers witch are moving trough the sceen an will be repositioned again. And they will move faster and faster and this supports a larger offset, because i think if theyre outsite the screen they will not be replaced on the exact pixel (-1024 (maybe because of latency?))

    I thougth i will set it up like: if youre outsite the screen take the current position of the other tiles get their width, and place the repositionated tile exact behind that.

    I was hoping that this will avoid these gaps....

  • Would be great if you got some ideas

  • Got to place them relative to the last one.

    They are probaly the same instance.

    So (pseudo) Using a Family containing 'Sprite'

    Sprite < Sprite X < -1024

    Family > position of right most

    ____ Sprite > set position ... x = Family.x + 1024 (i suppuse they are 1024 width)

  • Hmmmm. i didn´t get it.

  • Congrats2u

    Here's a working example capx (r244)

    It doesn't use Families but is fairly similar to what 99Instances2Go suggested

  • OddConfection

    Just wow. This works perfectly! Thank you very much!

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