I am making a 2D side-scrolling action game with Unity.
When I tried to press Play to start the game, only the player character was not displayed on the screen.
I investigated and tried various things myself, but I could not solve it because I was a beginner and I did not understand it well.
Even if you don't get an answer, I would like to have other things to try and advice. Thank you.
The player character is displayed in the Scene view, Game view, and the camera preview of the Main Camera, but when the game is started in Play, it disappears from the screen and disappears.
However, the script applied to the player is functioning, and it is in the "state where you can control invisible characters".
All the other enemy characters, the ground, the background, etc. are always displayed, and the scripts applied to them including the player are all working properly.
When I launch the game, I get no error message.
I made the child object of the player independent, and applied a script that follows the player.
(Postscript) Originally, only the image disappeared while the script was running when the objects other than the player such as the enemy, the ground, and the background were able to operate the player in the empty space. I messed up somewhere (other than the script) to fix it, and now only the player's image disappears.
The script is working properly, and it seems that the invisible player follows the movement according to the movement.
Confirmed that Culling Mask is Everything.
Created to display the result screen for elapsed time and goals.
There is no change whether Render Mode is Screen Space-Overlay or Camera.
Version is Unity 2019.2.15f1 (64-bit)
The platform in Build Settings is for iOS.
Le @ DKRevel "How to make a game"
↓ Script applied to the player
Also, the image below is the state of the Inspector view when Player is selected in the Hierarchy view while the game is moving in Play.
↓ Game manager script (GManager)
↓ Stage controller script (StageCtrl)
Please give us your answers and advice.
Answer # 1
Sorry for the lack of explanation ...! Only the Inspector said that "I would like to give you a screenshot", the script is as the sentence in the question sentence ... I wish I could copy and paste the script so that it replaces the part written as "code" in the template that is inserted when the button with the "
" icon is pressed. I'm sorry to bother you ...
However, it seems to be a long script, so if you paste it in the question sentence, you may have hit the character limit this time. For the time being, I think it's OK to leave the screenshot as it is.
Suspected as a direct cause of the player not being visible during gameplay, it seems like the context of the camera and the player is out of order
In the camera script ...
transform.position = new Vector3 (PlayerPos.x, 0, -10);
For example, there are places where the X coordinate is made to follow the player, but the Z coordinate is fixed at -10. Therefore, it seems that the Z coordinate of the camera being played will always keep the position of -10.
On the other hand, in the screenshot you presented
The Z-coordinate of the player shown in -shows -4993.0, which seems to have jumped to the front abnormally. Since the Z coordinate of the camera is -10, I imagine that the player is behind the camera and far away, and I don't think it's reflected in the camera.
I'm sorry, but I'm still not sure why this happened. Before the game starts, the players are properly reflected in the Camera Preview and Game view, so at this point I think that the context is normal.
What is the positional relationship of each object in the Z direction before the game starts? Is the position of the player, camera, and other objects such as continue position objects normal?
If they are not suspicious, next time you run the game and observe the Z coordinate of each object, you may get further clues. I wonder if there are any unusual movements such as the player flying in the -Z direction ... (I think that it is unlikely as long as you see the script presented, but anyway it is a clue Is where I want to find).
As shown in the figure below, switching the "2D" button in the Scene view and observing the scene from an angle, or playing the game with the Scene view and Game view side by side at the same time may be useful for finding anomalies. not.
- c # - the player character of unity rotates
- c # - about player prefs for unity
- want to make the joints of a unity character bend according to gravity
- unity - river is not displayed well
- even if the ui is displayed in unity, it will be attached once, but then disappear
- [unity] the coordinates of the gameobject displayed by clicking the button deviates from the expected location
- lines displayed using unity mesh are not displayed properly
- c# - [unity] how to activate character and command separately with different buttons
- with excel vba, the character in the cell is divided and displayed by line break
- i want to partially hide the player with isometric tile in unity
- ◆unity◆ "textmeshpro" "spriteasset" is not displayed
- select unity and character controller creation method
- character acquisition/unknown string is displayed by getchar function of c language
- c # - function not displayed in unity event trigger
- the effect when the character appears in unity is inclined
- the model exported by fbx in blender is not displayed correctly in unity
- i want to specify the url with unity's video player in oculus quest
- how to change the character animation in unity
- c # - player production in unity (shooting game)
- c # - player production in unity (shooting game)
- c # - i want to play sound effects in unity's 2d block breaking game
- c # - i want the player to follow the camera (3d)
- c # - collision detection between the stage and the car is not possible
- c # - [unity] sprite cannot be changed from sprite renderer while animator is on
- consultation on improving the collision detection specifications of unity's 2d action game
- c # - unity2d 2d action suddenly i can't move horizontally
- about rantime error memory access out of bounds when executing unity webgl
- c # - please tell me how to use the additional components of unity's volunteer production
- c # - moving the unity scene doesn't switch as intended