As you can see, one of the conditions to add the force is rigidbody.velocity.y <= fanPower
However, gravity in my game can change so things will rotate sideways or upside-down. So this is not a good method to check if the ball is flying upwards with certain speed. I read that transform.InverseTransformDirection(rigidbody.velocity).y would get the local velocity on the y axis, but if I use this, it wouldn’t work. Why is that and how do I make it work?
I’m not exactly sure what you’re trying to do, but I’m going to guess that the dot product is what you’re looking for. (Among other things, it can be used to provide information about the relative orientation of two vectors. For example, you could use it to determine how the velocity vector is oriented with respect to the current gravity vector.)
Well actually the code above is not correct. I jsut reallized that. Now in my game, the gravity is a vector3 variable. I’ll need to get the velocity of the rigidbody in the opposite direction of the gravity. If the gravity is like Vecotr3(0, -1, 0), then rigidbody.velocity.y would work, but if it changes (and the gravity can change to any direction) then this won’t work. I don’t think that Dot would help me for this one. So don’t look at the previous post, the idea there is wrong.