0
\$\begingroup\$

The piece of code I want to write is where the game will check if the player is colliding with anything it will check this by looking at your y vector3 is under a certain number (its like this cause the gravity and collisions overall is a bit wonky) like if the players vector3 is under (0.0f, 1.0f, 0.0f) then the game will call that line of code again if you're above that vector3 it will not call it again. My main problem trying solve this is telling unity who to check for which I'm not to sure how to do it. Whenever I do try to implement it all I get is errors sometimes I get really close but I'm unable to implement it due to some issues within the if statements.

As stated before I never was able to get implement I'll update things if I do figure it out on my own.

\$\endgroup\$
2
  • \$\begingroup\$ What specifically did you try and what specific errors did you get? This seems like it should be as simple as if (myObject.GetComponent<Rigidbody>().velocity.y < threshold) { doThing(); }, so it's not clear to me what help you need here. \$\endgroup\$
    – DMGregory
    Commented Jun 22, 2023 at 23:29
  • \$\begingroup\$ If you want to check if the object is colliding with something, then why not use the OnCollisonStay method? \$\endgroup\$
    – Philipp
    Commented Jun 23, 2023 at 18:28

1 Answer 1

0
\$\begingroup\$
if (Player.velocity.y < 0.01f)
{
   // do thing
}
\$\endgroup\$
0

You must log in to answer this question.

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