- Home /
Question by
dsutherland · Nov 26, 2012 at 10:45 PM ·
collidercolliderscompound
How are compound colliders used?
So you can create a compound collider from having colliders on the children, but is there a way to reference it? I have a ship with a bunch of separate mesh colliders but I need to reference a single collider for my script. The script is supposed to ignore collisions between the ship and the projectile. This is what it looks like:
var range = 2000.0;
var ship : GameObject;
function Start () {
}
var particle : GameObject;
function Update () {
var direction = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if (Input.GetButtonDown ("Fire1"))
{
// Construct a ray from the current mouse coordinates
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
Physics.Raycast(ship.transform.position, ray.direction, hit, range);
// Physics.IgnoreCollision(this.collider, transform.root.collider);
// sphere.transform.position = hit.transform.position;
Physics.IgnoreCollision(ship.collider, hit.collider);
if (Physics.Raycast (ray))
{
if (hit.collider)
{
Instantiate (particle, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
}
// Create a particle if hit
//Instantiate (particle, transform.position, transform.rotation);
}
}
}
Comment
Your answer