Basically I set up a trigger when the player enters the trigger it spawns a explosion at the location where the player entered the trigger…Which causes a bit of lag
I want to know if someone can point me in the right direction
How could I get it to spawn the explosion in a different spot? rather its way a heador behind/ above the player…
My Trigger Code Is this
var Explosion : GameObject;
function OnTriggerEnter (other : Collider) {
Debug.Log("entered the trigger");
var Create: Rigidbody = Instantiate(Explosion, transform.position, transform.rotation);
}
function OnTriggerExit (other : Collider) {
Destroy(this);
}
I’m not sure about what you’re trying to do, but if you want the explosion to occur at some position relative to the player, you can define the spawn point based on the player’s transform. The only question here is: to which object this script is attached? I’m supposing it’s attached to the trigger object, not the player. In this case, the player will be defined by the other parameter:
// define a position based on the players position. In this case, the
// point is defined at 2.3m in the forward direction. Use transform.up or
// transform.right if you want other directions.
var pos = other.transform.position + 2.3 * other.transform.forward;
// instantiate the explosion (if you don't need the var Create, don't include it)
Instantiate(Explosion, pos, transform.rotation);
If the script is attached to the player, however, you should eliminate the other. reference when calculating pos