public string prefabPath; //法术预制物体路径 //public SpellsPrefab prefab; //public string itemPath; //public Transform spellsPoint; public void Cast(Transform startPoint) { SpellsPrefab sp = (SpellsPrefab)MonoBehaviour.Instantiate(Resources.Load <SpellsPrefab>(prefabPath), startPoint.position, startPoint.rotation); sp.spells = this; Debug.Log("Cast"); }
void OnCollisionEnter(Collision col) { SpellsPrefab magic = col.transform.GetComponent <SpellsPrefab>(); if (magic != null) { TextMesh go = Instantiate(Resources.Load <TextMesh>("Prefabs/damageNum"), col.contacts[0].point, Quaternion.identity) as TextMesh; go.GetComponent <Rigidbody>().velocity = new Vector3(0, 1, 0); //go.text = "-" + magic.damage; Destroy(go.gameObject, 0.3f); monster.actions.InvokeOnHitBySpells(magic.spells); } }