I’m currently using Drag in my player gameobject’s Rigidbody to limit how far the player is pushed after being struck with a moving projectile. However, this is also affecting the player’s jump function, causing it to sort of glide in the air as the drag makes it descend slowly. Is there a way I can prevent the drag from affecting the z-axis so this doesn’t happen? Or perhaps another way to limit the push from projectile collisions so I don’t need to use drag at all?
Drag is just multiplying velocity by almost 1. You can set Physics drag to 0 and apply drag yourself in FixedUpdate. I do things like this when I need a particular “feel”:
Vector3 vel = GetComponent<RigidBody>().velocity;
GetComponent<RigidBody>().velocity = vel;
Then you can do little tricks, like increasing it after you’ve flown for a second or more:
float drag=0.98f; if(Time.time+1.5f>lastBumpTime) drag=0.95f;
// apply drag:
Thanks for your suggestions, but I found the most effective solution- for my case at least- is to just use Drag and change the physics.gravity of the desired axis to essentially cancel it out.