Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
0
Members

[Resolved] AppendScene, p2, and actor position

A topic by Ikalou created Sep 02, 2016 Views: 406 Replies: 3
Viewing posts 1 to 4
(1 edit)

Hi all,

Sorry if this is a silly question, but is it possible to move an actor to some position after it has been added with appendScene?

This works:

const spawner = new Sup.Actor("Spawner");
spawner.setPosition(SomePosition);
Sup.appendScene("Prefabs/Patterns/World1/Pattern1", spawner);

But this doesn't (it appears at the origin instead of at SomePosition)

const pattern = Sup.appendScene("Prefabs/Patterns/World1/Pattern1")[0];
pattern.setPosition(SomePosition);

My "Pattern1" scene looks like this, with a single actor at the root:

- Pattern

- Ground

...

- ...

I don't know the desired position of the actor ("Pattern") until after I create it, so the first solution doesn't really work for me.

Any help is appreciated. Thanks.

(Edited the title to reflect that this is not strictly a appendScene issue)

Any possibility your scene have an arcade body component? if true, your second method wont work cause you can't move an arcade body with .setPosition method, you would have to use warpPosition() method.

Hi,

I'm using p2. You're right, thank you, if I remove all p2 bodies from my scene setPosition works as expected.

I assume there is a p2 equivalent to arcade body's warpPosition()? But then, do I have to call that method on every single p2Body in my scene hierarchy after I append it? Is there no simpler/better way?

Thanks again for the help.

After trying various things, I'm just going to give up and individually move all the p2 bodies in my scene/prefab.

As soon as the scene components awake, their global position is tied to that of their p2 body, so I don' think there is a way around it