Game Development Asked by Spottel on December 1, 2021
As shown here, Paper Mario’s jump takes 8 frames go reach the max jump height and 12 frames to get back to the ground. This is pretty unusual, any idea how to jump up that quick with a rigidbody?
I tried to AddForce
when rigidbody.velocity.y > 0
, but that didn’t work out.
Any help would be appreciated, thanks in advance!
//Jump when pressing button and on ground
//jumpForce is a public float variable
if (Input.GetButtonDown("Jump") && isGrounded)
{
theRB.velocity += new Vector3(0, jumpForce, 0);
}
When jumping, set a flag (e.g., isJumping
) that indicates that the player jump is in action. Then, in update make checks if the vertical velocity is negative (falling down) and player is jumping. If it is:
for Rigidbody2D - reduce rigidbody's gravity scale to 0.67 (8 / 0.67 ~= 12
).
for Rigidbody (3D) - add velocity as such: rigidbody.AddForce(Vector3.up);
When player hits the ground, restore gravity scale to 1 and remove isJumping
flag.
Answered by eLTomis on December 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP