# Help With Theory - Energy Shield Flare Positions

Good evening, everyone.

I’m currently working on some code to create a flare against an energy shield. I have the code and behavior in place to create the flare in the proper location, however I am running into trouble when I try to rotate it in order to align it with the shield mesh. For testing purposes, this mesh is currently set as a squashed sphere.

The code is currently set to rotate the flare object so that it faces the pivot point of the shield bubble via the transform.LookAt function. Unfortunately, this really only works if the shields are a perfect sphere, which they are not.

The projectile is set up with a trigger collider for collision detection. The shield object has a script to detect that collision and act appropriately as far as destroying the projectile object and instantiating the shield impact effect.

What I am currently unclear on is whether or not there is a method to detect collision contact points when the colliding object is a trigger event. Currently, the collision handling is taken care of via OnTriggerEnter. From what I can tell, this function does not contain any contact information as to the point of impact. With that in mind, is there possibly a way to determine the normal of the shield object that is nearest to the point of the trigger (ie, the flare object position)? I believe I could set the rotation properly with that information.

If current code is required, I will post it once I get home. Additionally, I will also post images to illustrate the problem I am running into. In the meantime, I would welcome any suggestions!

Thanks,
-Lance

RaycastHit.normal is the way to go. Create a ray at the forward axis of your projectile, then read the shield by tag.

Here is a OnCollisionEnter Version

function OnCollisionEnter (collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
}

You can have the bullet look for collision with the shield and do the damage and everything of the sort instead of looking for the collision in the shield.