Search Unity

Question Adding Gravity to a First-Person Player

Discussion in 'Visual Scripting' started by BubbleGobbler, Oct 29, 2022.

  1. BubbleGobbler

    BubbleGobbler

    Joined:
    Aug 23, 2022
    Posts:
    7
    Hello, I am here with a question about first-person controllers. I am a beginner game developer, and I am trying to make a player character for an fps game. Currently, I have an issue simulating gravity with the player.
    I tried to include gravity by adding a constant force to the player. I planned to prevent the player from clipping through the ground through this method: First, I made an empty game object and attached it to the bottom of the player. I then added a collider and some code so that if the empty object collided with the ground or any object, the gravitational force would equal 0 and the player would stop falling. However, whenever I tested the game, the game would pause and present an error message as soon as the player hit the ground. This is the error message:

    upload_2022-10-29_15-30-31.png

    The code:
    upload_2022-10-29_15-28-53.png

    upload_2022-10-29_15-29-18.png

    I appreciate any help I can get. Thank you!
     
  2. BubbleGobbler

    BubbleGobbler

    Joined:
    Aug 23, 2022
    Posts:
    7
    I actually just fixed my issue, so this thread is unnecessary. However, feel free to post the solution so that others can learn from it.