[Newb] I was following the first tutorial - bonus_star.go is invisible?

I was following the first tutorial called “Side scroller tutorial”. I ran into an issue, the bonus_stars objects are invisible - They are correctly spawning and I am collecting them but they are not visible.

I checked that I added a sprite to bonus_star.go, set the image to stars.atlas and set the animation to bonus_star. No luck.

I added the particle effects from star.go and they show up correctly.

Hiya,

Check the “z” position of both the sprite and the GO. They add together. Anything below -1 or above 1 won’t render.

@ryanscottlandry
Sprite Z Position is set to 0. I’m guessing GO means .go file - which I don’t know how to check the Z position of. The properties section of bonus_star.go doesn’t have a position.

You need to open the collection which contains the game object and select it there.

I found main.collection it references factory.go. It’s z value is .5 (Changing to 0 changes nothing).
It contains both bonus_factory and star_factory.
Since this factory contains both star and bonus_star.go, and star.go is visible, I don’t believe this should be an issue.

Check the z-value of the bonus star sprite and make sure that final z-value it doesn’t fall outside of the visible range (or possible behind the background graphics). Read more here:

I updated bonus_star.script update() method to:

function update(self, dt) local p = go.get_position() print(p) p.x = p.x + speed * dt if p.x < -32 then go.delete() end go.set_position(p) end

And this outputted:

DEBUG:SCRIPT: vmath.vector3(1312, -274.89022827148, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -276.25689697266, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -277.62634277344, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -278.99856567383, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -280.37356567383, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -281.75134277344, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -283.13189697266, 0.5)
DEBUG:SCRIPT: vmath.vector3(1312, -284.51522827148, 0.5)

Which makes me believe that it isn’t a z-value issue.

But again, first time using this. No idea.

Please also print go.get_world_position()

And if that fails please zip and share the project

This also printed out a z position of .5

Here is the project:
Side scroller tutorial.zip (2.8 MB)

Thanks for the help!

It’s not that the star is invisible, it’s just off the screen. If you look at those numbers, the X position is not changing, it’s the Y position that is slowly going down. To be honest I have no idea…Ah! Nevermind I found it. The collisionobject on the bonus star is still set to Dynamic, so it’s physically simulated and set_position doesn’t work on it, it just slowly falls because of gravity. Just set that to Kinematic and it’s all good.

5 Likes