Forum rules - please read before posting.

Player character has gravity turn on and refuses to move when transitioning scenes.

In my project I have a player character, and this player has a rigidbody on it to detect collisions. Everything works fine, but in certain scenes when I load them up, the player character's gravity modifier turns from 0 to 1 and continuously sets to 1 when I try to manually change it. Also the character refuses to respond to the arrow keys correctly. I don't even know where to start looking for a solution to this, as I don't see any reference to the gravity or rigidbody in the player script.

Comments

  • Is this for a 2D or 3D game, and is your Player character present in the scene file - or spawned in at runtime?

    The gravity option is set by the Player's Ignore gravity? option, under the "Physics settings" panel.

    If the Player isn't moving, do you have "Apply Root Motion" checked in their Animator?

  • edited June 2023

    This is a 2D game and the character is present in the scene file. I'm fairly certain the ignore gravity is checked on, but that may also be automatically turned off. I can get a video of the issue when I'm working with my student today.

  • Here's a video of the issue. Interestingly it seems to only happen when transitioning back to a scene/transitioning twice. Whichever of the two scenes we start in is where it happens. Sorry we couldn't keep the inspector open when transitioning scenes.

  • I'm afraid the video is private. You can mark it as "unlisted" if you want to avoid it being searchable, but still embeddable.

  • @ChrisIceBox Sorry I thought it defaulted to unlisted. Should be good now.

  • Thanks. The video shows the issue, but I'll need to see the Player's full Inspector (including their Rigidbody 2D) both before and after the issue occurs. It gets hidden in the video because the Player is a separate object for each scene - but if you pause the game mid-scene, you can find and select the scene's Player object to view their Inspector.

    A local Player's gravity state will be saved as part of that scene - so if it's occuring when you re-enter, it suggests the state has been changed the first time you entered.

    What Actions are running while the scene is open? The Player: Constrain Action can be used to alter the Player's reaction to gravity.

    As an aside: are you using the Rigidbody to avoid collisions with the walls when using Direct control? It may not be necessary - as of v1.77.0, the Player's Auto-stick to NavMesh? option can be used to have a 2D character be bound by the confines of the active NavMesh - without need for colliders.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.