Hello
I made some GameObjects. When I play the Game, they fall down in space. What do I do to prevent them from falling?
Hello
I made some GameObjects. When I play the Game, they fall down in space. What do I do to prevent them from falling?
Perhaps donât make people guess by only putting âI made some GameObjects.â
GameObjects donât fall so I have to guess youâre using 2D physics? If so then you shouldâve said you donât want Gravity to be used on some (all?) of them. Set gravityScale to Zero on the Rigidbody2D in question. Of course, this is a guessing game right now.
Hi
Sorry for the simple Questions without adequate data. I am a newbie.
Yes you are right. I am using 2D physics. I did set the gravityScale to Zero. Now they are going up instead of falling down.
I have taken a snapshot of what I am doing. Hope that can assist you in your analysis.
(2DGame-Error.PNG - Google Drive)
Cheers
Deepak
If theyâre going up then youâre doing something to them such as adding a force or modifying the position in script.
It sounds like gravity was causing them to move down countering what you were doing moving them up and now youâve removed gravity, whatever it is youâre doing is moving them up.
This isnât Unity doing this, itâs your code so I cannot really tell you anything else.
I mean, add a Rigidbody2D to your scene with a sprite and set gravity-scale to zero, itâll stay there.
You donât even say if itâs one platform or all of them! I suspect all of them.
I think what youâre telling me is all wrong. If I had to guess, because your camera is a child of the player, the âmoving up and downâ is actually the player along with the camera. The platforms are staying still which youâd easily be able to see because their Transform position (in your image) wouldnât move. The platform you show has the BoxCollider2D disable so the player will fall through it.
I think you need to just step back and check your set-up. Try NOT having the camera follow the player like that so you can get your bearings.
There is no script for the Platform-GameComponent. The funny thing is the âPlatformâ gamecomponent is now static (it stays there). However if I create a exact copy of it(Platform1) and place it in the scene, it moves up!
Did you read what I said about the camera and the player?
It just looks like the player is falling and the camera is following.
I cannot tell you âhow to fix itâ. If this is the tutorial you followed then why can you not go over the tutorial again and fix your mistakes?
Ok. I went through the tutorial many times, however without success. Anyways, thank you very much for your help.
I saw in your video that the player is rotating so I guess you didnât see the option that stops that here:
âWe also want to fix our orientation to prevent the character spinning and freewheeling around. Find âconstraintsâ in the inspector with the player selected and tick the box to freeze rotation Z. Now click play again and you should find your player now drops from the sky to his infinite doom.â
Also, it looks like the Platforms in your video are moving but in the tutorial, they are not so you should not add a Rigidbody2D to them otherwise theyâll move when the player touches them. In the tutorial only a BoxCollider2D is added to the platforms, to give the player something to collide with. They do not need to move so by NOT adding a Rigidbody2D they are implicitly Static colliders i.e. not moving.
The tutorial for set-up is easy:
Hope this helps.
I tried fresh again. It works. Thank You
Good luck learning. It does get easier as time goes on.
Thank you so much