Anchoring actor 1 to actor 2 [Solved]

Donni11

  • *
  • Posts: 2181
Hello,

How would I anchor actor 1 to actor 2 ( without using the joint extension) ?

« Last Edit: June 30, 2017, 11:01:08 am by Donni11 »
Peace

gurigraphics

  • Posts: 690
When update set positionX and positionY of actor_1 in actor_2 ?

JeffreyDriver

  • Posts: 2262
I frequently do this by creating global (game) attributes to record the X and Y value of the player. Then it's just a case of recalling those attributes to place your other actor.

Donni11

  • *
  • Posts: 2181
Sorry for a bumping this old topic,
This is what I tried:


Nothing is happening, any solutions?
Peace

JeffreyDriver

  • Posts: 2262
It should work. What are the physics settings for your actor? Could there be some other code overriding it?

squeeb

  • Posts: 1617
Make 2 attributes and set x to the attribute and set y to the attribute in always event.. do every N seconds makes it look jagged.. then set the attribute to x center of actor  and the other to y center.. or however you choose to tell it where to go

Donni11

  • *
  • Posts: 2181
@JeffreyDriver, No other code overriding it. Here are my settings: ( are they good?)
Peace

JeffreyDriver

  • Posts: 2262
The settings are good. Can you post the rest of your code for your actor?

Sqeeb's solution will work. Use global attributes to record the XY values, then recall those for the other actor.

Donni11

  • *
  • Posts: 2181
Can you post a screenshot?
Peace


Donni11

  • *
  • Posts: 2181
Still not working. The anchored actor works fine ( using anchor behavior) however the second actor ( the actor that is being double anchored ) still isn't moving.
Peace

JeffreyDriver

  • Posts: 2262
There must be something else in your code or settings that's stopping it. Can you post your code.

Donni11

  • *
  • Posts: 2181
I think I figured it out, why this way won't work. The coords don't change when a actor is anchored, it is just a screen trick. Stencyl looks at is as if the actor is still in its original place, hasn't moved. I know this because I coded the game to post the current coords to the console of the anchored actor every 1 second. The coords haven't changed even when I scroll and it looks like the actor is moving. That explains why the second actor wasn't moving. Because the first actor coords have not changed.

Now I need a new way to do this.
Try doing it yourself, it won't work.
Peace

Donni11

  • *
  • Posts: 2181
Anyone have any suggestions?
Peace

JeffreyDriver

  • Posts: 2262
Instead of anchoring the actor, you can just set it to a fixed position relative to the camera in an 'always' event, then use the above method.