- Home /
Colliders Not Doing Their Job
So I have a pretty annoying problem.
I've been using the FPS Constructor Weapons Package V 0.95 to throw some weapons together really quick, however, one weapon in particular, the rocket launcher, is not behaving like I would want it to.
Basically the rocket only hits the surface of my boxcollider-based floor about 80% of the time, and only hits my meshcollider-based surfaces about 10% of the time. Now I've heard about how mesh colliders can be worse for fast traveling rigidbodys etc. but I certainly am not going to manually put primitive colliders into my ENTIRE map.
I've heard of solutions to this "quantum tunneling" problem, that include raycasting and other techniques but I really have no idea where to start on this. Any input is welcome.
Here is the related script for the grenade/rocket function:
grenade.js
var delay = 1.0;
var timeOut = 1.0;
var detachChildren = false;
var explosion : Transform;
var explodeAfterBounce : boolean = false;
private var hasCollided : boolean = false;
private var explodeTime : float;
//private var hasExploded : boolean = false;
function Start (){
explodeTime = Time.time+timeOut;
}
function OnCollisionEnter (collision : Collision){
if(hasCollided || !explodeAfterBounce)
DestroyNow();
yield new WaitForSeconds(delay);
hasCollided = true;
}
function DestroyNow ()
{
// if(hasCollided){
if (detachChildren) {
transform.DetachChildren ();
}
DestroyObject (gameObject);
if (explosion)
Instantiate (explosion, transform.position, transform.rotation);
// } else {
// return;
// }
}
function Update () {
var direction = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if(Time.time > explodeTime){
DestroyNow();
}
}
Thanks for all the help!
~TacoShank
Answer by Eric5h5 · Nov 05, 2011 at 05:20 PM
Use continuous dynamic for the collision detection instead of discrete. And/or increase the rate at which physics runs in the time settings; by default it's 50fps (.02).
Well using continuous dynamic doesn't have an effect on the box collider at all, and it makes the rocket bounce off of the mesh colliders. Also, I don't want to sacrifice efficiency by going with a higher physics rate, there has to be a better way of doing this.
Answer by Persona · Nov 05, 2011 at 05:16 PM
You can set up so that when the distance between a rocket and an object with a wall tags is less than 1 unit away, have it detonate.
How is this any different then using colliders? That 1 unit away window would be prone to the exact same problems as the colliders wouldn't it?
Your answer
Follow this Question
Related Questions
Physics.Raycast not checking layermask properly? 1 Answer
Get a bounding sphere for collider/rigidbody? 0 Answers
Creating a SIMPLE car. 1 Answer
Same reaction with different number of objects colliding 2 Answers
Manual collision check 2 Answers