"for some context, I have a character who's movement is based off exerting force
in a set direction. currently, it can be pushed infinitely and I want to prevent
"for some context, I have a character who's movement is based off exerting force
in a set direction. currently, it can be pushed infinitely and I want to prevent
"for some context, I have a character who's movement is based off exerting force in a set direction. currently, it can be pushed infinitely and I want to prevent the player from pushing the character into the stratosphere. "
I don't think increasing the mass is going to have the effect you desire. Quoting from the Unity docs:
"A common mistake is to assume that heavy objects fall faster than light ones. This is not true as the speed is dependent on gravity and drag."
"for some context, I have a character who's movement is based off exerting force in a set direction. currently, it can be pushed infinitely and I want to prevent the player from pushing the character into the stratosphere. "
I don't think increasing the mass is going to have the effect you desire. Quoting from the Unity docs:
"A common mistake is to assume that heavy objects fall faster than light ones. This is not true as the speed is dependent on gravity and drag."
object::update()
{
if self::touchingGround() { // Check if the ground is right bellow
self.applicableForce = 100.0; // My arbitrary max force
} else {
// If not touching ground, reduce applicable force to 75% each frame
self.applicableForce = self.applicableForce * 0.75 * deltaTime; // Adjust with the delta time
}
// Check input
if getInput("up") {
self::applyForce(directionVector * self.applicableForce) // Apply the force in the rigid body (self)
}
}
it will have to based on altitude, not time. otherwise they could push it sideways until it would no longer move.
you could just limit the altitude, or make the force a function of altitude. F effective = F in / alt. that sort of thing.
both good ideas, I'll mess around and see what I can create with your suggestions,
I think I want a hard cutoff so for example... after 5 seconds in the air the player loses all control and falls in whatever direction they were previously accelerating.
Thanks again!
i'd say altitude too, a weird poor-man's way might be to
density += velocity.z * factor * dt;
at each step.
it will have to based on altitude, not time. otherwise they could push it sideways until it would no longer move.
Using mass to constrain the player to the world sounds like a really bad idea. Why can't you just limit the velocity and not apply forces after a certain theshold?