Hello. I’m trying to create a game where your character’s movement is based on where you are shooting. So if you shoot down, it’ll essentially be like jumping. I have two guns, so you can be shooting downwards with both to speed up your ascent.
I’m having a bit of trouble with the creation of the projectile. When I add the impulse to the character without creating a “Shot” prefab, my character moves as expected (smoothly moving upwards when both guns are shooting downwards or slightly to the side). However when I create the projectile, sometimes it seems the character gets stuck or something on the prefab, causing the movement to be jerky and unsmooth.
I’ve tried playing around with my “Shot” prefab, removing its rigidbody and collider and such. It seems that when the collider is not active, this problem doesn’t exist and the character can move smoothly. However I am going to need that collider to perform other checks.
Another thing I am doing is calling Physics.IgnoreCollision. This seemed to work in terms of my projectile not getting destroyed when it hits the character, but the jerkyness still exists. Here’s my code for that call:
GameObject shot = Instantiate(projectile, hand.position, hand.rotation) as GameObject;
Collider colliderBody = transform.parent.GetComponentInChildren<BoxCollider>() as Collider;
Physics.IgnoreCollision(colliderBody, shot.collider);
shot.SendMessage("SetVelocity", -firePower * firePower * lastRotation);
I am thinking maybe there’s another rigidbody it’s getting stuck on within my character, but I don’t have any colliders or rigidbodies attached to it besides the one that it’d find with GetComponentInChildren BoxCollider(). Any suggetsions on what I can do to fix this jerkiness?