[Resolved][Display] Sprite does not appear in Play Mod

Hello everyone,

I am a beginner and I am doing my first tutorial in Unity.
I am following the Ruby’s Adventure 2D tutorial.
Very clear, very easy to follow.

But I have an issue.
I can see my sprite in the Scene View, I can also see my sprite in the Game View.
But each time i add a Script to a sprite suddenly i cannot see this sprite in Play Mode even though I can see that the scrpit is working if i look at the sprite coordinates.

It is weird because i am following exactly the instruction of the tutorial.

Anyone knows what could be the issue?

Thank you for your time,

Pascal

tutorial says, the script moves the sprite outside of view,
"Click the Play button to enter Play Mode and admire your first scripting result: a character rapidly fleeing to the right that quickly goes off the screen! "

so i guess its working as intended, maybe in coming steps you will make the camera follow it or something else?

Hello mgear,

Thank you for your answer.
This is what I thought at first… That the sprite was going too fast to be seen.

Until I reach step 7 of Character Controller and Keyboard Input where I am supposed to control the character.
If I check the coordinates I can see that the character stand still until I press directions.
When I press directions I can see the coordinates changing.
But I don’t see the character.

Actually, what I’ve noticed is that each time I add a script to a sprite, the sprite is not displayed in Play Mode.
Sprites wit no script appears in Play Mode.

Thoughts… ?

Pascal

can you show the script? maybe it moves sprite at Start when you hit play.

Hello mgear,

Please find enclosed a screenshot of my script in (taken in visual studio 2017).
I have just copy-pasted what was in the tutorial.
Hope it helps,

Pascal

ok, its moving the transform even if you don’t press anything,
that line 19, its using current position.x and then adds it there again…
not sure whats the reason there, but maybe if you follow the tutorial, it gets modified further?

Hello mgear,

I re-test again.
If I am not mistaken, Input.GetAxis(“Horizontal”) return 0 If I don’t press any inputs; which means that 0.1f * horizontal return 0 also; which means that my character x coordinate is not supposed to change = the character is not supposed to move.
When I look at the Console I can see that the Character is standing still.
But I still don’t see it in Play Mode

But I’ve noticed that in Scene view I can see the SPrite changing position as I move it.

Thank you again for your help,

Pascal

oh i see, misread the line with +=

whats your sprite Z value in inspector, and what about camera z ?
(if the sprite is outside of camera view)

Hello mgear,

Yes it was about the Z value.
I think I have understood the crime.

My camera clipping plane near value was 0.3.
My Sprites Z value was more than 0.3 so they were supposed to appear.
But somehow they were disaperaing when going to Play Mode.
I’ve notive that in Play Mode the Sprites who had a script had their Z value turned into 0.
So I’ve changed the camera clipping plane near value to be -1.
And TADA!!!

I assume it is because of the Vector2 variable type who must turn any Z value of a Sprite into 0 since it is a 2D vector.
It might actually be a 3D vector with Z always equals 0 (x, y, 0).

Not a trivial one.
They should clearly make a statement about that in the Tutorial.
That the Z value must be checked in term of Camera, Sprite position and any function that could alter it.

Thank you for the help on this!!!

Pascal