Skip to main content

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

Prefab loading

A topic by pixelrobin created Jan 14, 2016 Views: 760 Replies: 6
Viewing posts 1 to 7

I had some issues with appending scenes as prefabs, mainly with the actors' arcadeBody2D (Here's a gif). I emailed SparklinLabs about it and they replied with a solution (thanks!).

But in the solution, some code was taken out. Before It was like...

Sup.appendScene("CavemanPrefab", Sup.getActor("Cavemen"));

And this was the solution I got sent, which worked perfectly.

let caveman = Sup.appendScene("CavemanPrefab")[0];
caveman.arcadeBody2D.warpPosition(Sup.getActor("Cavemen").getLocalPosition());

However, I want to parent the appended Caveman actors to the Cavemen actor for collision reasons and stuff. But, when I do, the bug happens again, but not in the same way (here's a gif).

Here's what I tried:

let caveman = Sup.appendScene("CavemanPrefab", Sup.getActor("Cavemen"))[0];
caveman.arcadeBody2D.warpPosition(Sup.getActor("Cavemen").getLocalPosition());
let Caveman = Sup.appendScene("CavemanPrefab")[0];
Caveman.arcadeBody2D.warpPosition(Sup.getActor("Cavemen").getLocalPosition());
Caveman.setParent(Sup.getActor("Cavemen"));

What am I missing?

Moderator

Hello! I'm the one who replied to your email ;)

Does the position of your "Cavemen" actor matters ? If not, I think its position wasn't on (0, 0). It may be the cause of your troubles (it shouldn't mess things up, so there is probably a bug somewhere). So could you try move it to (0,0) and report ?

(2 edits)

Tried it, no avail :). They don't appear at all if I set the Cavemen actor (the group) to 0, 0 and the the prefab to the desired location and they flash if I do it the other way around.

EDIT: Wait, could it have something to do with how parent actors move all of their children when moved?

Moderator (1 edit) (+1)

Making some progress. I found the culprit!

this.actor.arcadeBody2D.setOffset({ x: 0, y: 0.2 });

Changing the offset somehow mess things up. Now looking for a solution!

EDIT: Found it! There was a bug and it will be fixed in the next release.
Both your propositions are valid and will work then ;)

Moderator(+1)

Here's the related commit for anyone wondering: https://github.com/superpowers/superpowers-game/co...

Was the fix part of update 0.19.0? Because the glitch is still occurring in that update :).

Moderator(+1)

No the 0.19.0 was released yesterday so it will have to wait for the next one sorry.