0
\$\begingroup\$

I have a player who can jump. I want the character to stay in its position and not fall to the floor.

This is the code I am using so far:

private void FixedUpdate()
{
        if(moveup)
        {
            rigid.AddForce(new Vector3(0, 1f, 0) * speed, ForceMode2D.Impulse);
            moveup = false;
        }
}

How can I stop the character from falling?

\$\endgroup\$
0

1 Answer 1

-1
\$\begingroup\$

Just change the

void Update()

to

void UpdateFixed()

I hope this solves your problem.

But turn off the collider for the player and make sure you have a rigidbody on ALL assets.

Also, make sure the character isn't in the ground when the game starts.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It's FixedUpdate, not UpdateFixed. They already use FixedUpdate. Also you provide a lot of things they should check, but no reason for doing so; better teach them how to fish than just provide them with the fish. \$\endgroup\$
    – Vaillancourt
    May 21, 2021 at 10:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .