Hi,
The question is i have enemy when he gets hit by a bubble which is the palyer' bullet
I want him to a child of the bubble and set in the center of the bubble
-- the centering issue is not working well any ideas: thank you
var upuogo=1.7;
var enemyhurtsound: AudioClip;
var damage = 10;
// move the bubble add force whe we shoot it out but this one makes it go up a little bit
function FixedUpdate () {
transform.position +=Vector3(0, upuogo, 0) * Time.deltaTime;
}
// colliding with enemy
function OnCollisionEnter(other: Collision){
if (other.gameObject.tag =='enemy')
{
//make the speed up faster
upuogo=3.2;
// make bubble the parent of the enemy that was hit
other.transform.parent=transform;
// ignore colliding with your child
Physics.IgnoreCollision(other.collider, transform.root.collider);
//send a message this enemy is caught >> idle + cannot shoot
other.gameObject.SendMessageUpwards("caught", SendMessageOptions.DontRequireReceiver);
// put the child in the center of the bubble (does not work well)
other.transform.position=renderer.bounds.center;
//this also does not work well
//other.transform.position=transform.position;
//this is for the length he is caught
yield WaitForSeconds(2.0);
//play hursound
AudioSource.PlayClipAtPoint(enemyhurtsound, transform.position);
// apply damage
other.gameObject.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
//let him go
other.transform.parent=null;
//send message that he is free (walk + can shoot, or patrol)
other.gameObject.SendMessageUpwards("release", SendMessageOptions.DontRequireReceiver);
//resent the bubble speed
upuogo=1.7;
//destroy the bubble
Destroy(gameObject);
}
}