How to make Objects so as they do not leave an area around another object
Hello, I need to make it so that some objects do not leave a circular area of which the center is another object.
So these objects can have random movement until they reach the boundaries of the circumference around the center object.
I have been looking at insideUnitSphere but I do not think that this is the correct function for the job!
Any help will be appreciated :)
Thanks in advance!
Have you already tried using Vector3.distance? That should allow you to easily check how far away one object is from another (even in 360 degree scenarios). $$anonymous$$aybe you've already experimented with it though.
Answer by HashBrow · Feb 15, 2017 at 09:32 AM
Hello, thanks for replying :) @chubzdoomer I was using transform to allow them to move but that was a set height from each of the individual objects. I then had a separate function running to check for distance from center of position based on object.
When my allowed objects chose a vector3 to move to then they ended up trying to walk out of reach of my object, got to the boundaries of .distance and then flicked back and forth between the position they wanted to go and the circumference of the object they are restricted by
Your answer
Follow this Question
Related Questions
Center a Object at hit.point in Camera 2 Answers
How i can set Start Position and Ending position in ROTATION AROUND AXIS? 0 Answers
Cannot convert 'object' expression to 'float' 1 Answer
C# Find specific object by getting one of its variables 0 Answers
C# Limit touch movement on a raycast 2 Answers