hello again guys.
My main problem is this erro message:
Well… the script:
using UnityEngine;
using System.Collections;
public class CollisionClass : MonoBehaviour {
void Update() {}
void OnTriggerEnter(Collider other) {
// get shoot owner only if object is a "Shoot" tag
string owner = (tag == "Shoot") ? GetComponent<Shoot>().Owner : "Other";
// only do something if the collision doesnt belong to the owner
if (other.transform.tag != owner)
if (other.transform.tag == "Object") {
/* MAIN PROBLEM */
Transform obj = other.gameObject.GetComponent<RollRock>().ExplosionPrefab;
if (obj)
Instantiate(obj, other.transform.position, other.transform.rotation);
/* MAIN PROBLEM [END] */
Destroy(other.transform.parent.gameObject);
} else
Destroy(other.gameObject);
}
}
What happen? when the player shoot, the bullet touch the rock object… then i want the rock to blow (my “explosion prefab”).
Here is my RollRock script:
using UnityEngine;
using System.Collections;
public class RollRock : MonoBehaviour {
public Transform ExplosionPrefab;
void Start() {}
void Update() {}
}
There i already assigned my prefab.
The bullet prefab has a “Shoot” Tag, the Rock prefab has an “Object” Tag. Now what… What i’m doing wrong? when the bullet touch the rock… the CollisionClass activate then the rock destroy the bullet and the bullet shoud get the “ExplosionPrefab” and instantiate it.
Ps. Any more information there i can give, to help me… please let me know.
Regards.