- Home /
Move the enemy object opposite to player and keep its distance relative to the player?
Hi,
I'm new to unity 3d.This is my first sample 3d game. I'm trying to create a script that dog will runs after the sheep, where sheep runs away from the dog to the opposite direction of dog ,when dog comes nearer .(for example dog comes left side of the sheep,it will go to right side, if dog comes right side it wants to move left) . Finally dog wants to move the sheep into the house. After moving the sheep into house the game, stop the sheep's movement. I'm still learning scripting though!
Answer by OmarAlhaddad · Jun 19, 2013 at 12:54 PM
Look up Physics.RayCast:
Casts a ray against all colliders in the scene and returns detailed information on what was hit.
Let your dog fire those rays and use RaycastHit to find out where the hit happened.
Your answer
Follow this Question
Related Questions
Follow within a certain distance? 1 Answer
Distance destroy object 3 Answers
Unity Enemy Range detection 3 Answers
Edit this script so that the player stops at a distance and attack? 0 Answers
How to stop enemy within certain distance of player? 2 Answers