- Home /
object can still penetrate the collision
hello everyone, I'm a beginner and have a problem where the object can still penetrate the collision, maybe I can enlarge it, but it's not effective, for example I make a bullet and shoot at the target, it's probably normal if the bullet speed is low and the object will fall, and it doesn't work if the bullet is very fast, the target doesn't seem to touch the bullet and doesn't fall, is there a way to strengthen the collision or any way to overcome this, I might still be able to search the internet, but I have to use a dictionary, please help thanks
Answer by FuryFight3r · Jul 14, 2021 at 06:28 AM
Hi there Guserd, I had the same issue when I was first starting out, the reason this is happening is that the projectile is moving too fast for the collision to be detected, meaning that the detection is being checked usually 60 times per second (if you are running at 60fps) though as you can see with the video I have provided with my early tests with fast moving projectiles you can see that the bullet is skipping forward and not smoothly moving forward, what this was doing was when I was trying to shoot enemy's with this projectile it would only sometimes detect the collision, though most times it would miss the collision all together as the bullet was never actually touching or inside the collider it skipped right past it, I never did get around to making a work-around for my early tests, though you can get more precise collision detection by going to both your Bullet/Projectile Prefab's Rigidbody and changing the 'Collision Detection' to 'Continuous' (which keep in mind is more demanding on the PC than say discrete, but allows for more precise detections), also by doing the same on your enemy Rigidbody this can help with detecting if the projectile is either touching or inside the collider. If this fails your only hope would be to make the Projectile speed slower, which in turn that would mean (if you have bullet drop that is) you would need to make the bullet be lighter (by lowering the 'Mass' on the Rigidbody) to compensate for the speed change, just so the bullet doesnt drop straigh to the floor upon firing.
https://www.youtube.com/watch?v=Lx9qW0pUzQI
I hope this has helped :)
thanks, I've tried, it's still the same, but look at this, there is a capsule and a barrel:
even i've tried to change the default collider to collider of cube which is big enough, oh yeah when the obstacle moves and i stop, it doesn't work, but when i walk while hitting it, it works, please help
I am struggling to understand what it is you are actually trying to achieve.. In your OP you were stating about a bullet not hitting a target, but now you are talking about a Barrel, I don't understand what it is you want to happen?
So let me try and understand, do you want the barrel to knock the player off the platform? or is the player meant to remain on the platform and barrels move around the player? or is the player suppose to avoid the barrel, but if the player touches the barrel it kills/damages the player? (Assu$$anonymous$$g the capsule you have in the screenshots is the player?)
Please provide more precise information about what you want to happen and what is actually happening, so I can correctly help you. Also please provide the code you are using to detect the collision between the player and barrel as there is multiple ways a collision can be detected... Upon Entering collider (which is a one-time call of the first frame that it had detected the collision), upon Staying inside the collider (which is called once per frame as long as these 2 colliders are staying within each other) and the last is upon Exit Collider (which is the same as the Enter function except it is a One-Time call that is done upon 2 colliders exiting each other)..
Just as a pure guess by the looks of the screenshot it seems as though your barrel (both the Box Collider and Mesh Collider) is set to a Trigger, which being set as a trigger means the player can walk inside this collider, but it still sends a signal to any listening 'Enter/Stay/Exit' functions, also using OnTriggerEnter() perse will not work with a collider that is not set as a Trigger and the Same with a non-Trigger collider will only work with the OnColliderEnter() functions.. However I really cannot help you any further unless you actually explain to me what you want to happen more clearly.
ok, in advance sorry, i had some problems like the bullet failed to fire, and this one too, i'm also still using g translate, it might work on the bullet that failed to fire, and now the barrel is working fine too, thanks for the answer worked
Your answer
Follow this Question
Related Questions
Different particles for different collisions. 1 Answer
Elastic Collisions with Rigidbodies 1 Answer
Check collisions with more than one enemy? 1 Answer
Help with a killbox 1 Answer
Particle collisions for a NOOB?? 1 Answer