Quantcast
Channel: Questions in topic: "contact"
Viewing all articles
Browse latest Browse all 75

OnTrigger AI projectile detection and turn.

$
0
0
Ok I need to get my AI to notice bullets being shot into his line of sight and him. He has 2 colliders, one is a trigger which is the vision collider and the other is the capsule collider on the AI itself(not a trigger). What I need is this fool to detect or reference the angle at which the bullet is shot at him and start moving in that direction. Code so far: void Update(){ if(startSearching == true){ Searching(); } } //The hell am I doing lol? I don't know. void OnTriggerEnter(Collision colp){ var contact = colp.contacts[0]; if(status == Status.Idle){ targetDirection = Vector3.Reflect(transform.forward, colp.contacts[0].normal); startSearching = true; } } void Searching(){ // This makes it go forward. vSpeed = 1; // and this is the turing to contact point. tansform.rotation = Quaternion.LookRotation(targetDirection); }} So what I am trying to say is... This whole thing does not work, I am very confused and please halp!!

Viewing all articles
Browse latest Browse all 75

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>