- Home /
can you call a object after other object have been rotated?
something like i the arrow to face each other then after i face them an object will be called can i called the object? how? pls i want it to be specific to face each other then call the object something like puzzle maze or something
I think your question is basically, you are rotating an object. After rotating, you want to do something else. I'm not sure what you mean by "call" though. Do you mean activate an object? Or call a specific method on an object?
Answer by muckenhoupt · Sep 25, 2020 at 10:33 AM
This is a difficult question to parse, so I may be interpreting it wrong. If I understand correctly, you want to detect if two objects are facing each other. Probably the simplest way to do this is to do a RayCast from each object, which would look something like:
float maxdist = 1000;
Ray ray1 = new Ray(obj1.position, obj1.forward);
Ray ray2 = new Ray(obj2.position, obj2.forward);
RaycastHit hit = new RaycastHit; // We just need this for the Raycast call
bool hit1 = obj1.Raycast(ray2, hit, maxdist); // True if ray2 hits obj1
bool hit2 = obj2.Raycast(ray1, hit, maxdist); // True if ray1 hits obj2
if (hit1 && hit2)
{
// Do your stuff
}
Your answer
Follow this Question
Related Questions
2D Rotation for aiming problem 1 Answer
2d top-down rpg direction check 1 Answer
How to get an enemy to go to a location and then return. 1 Answer
Prefab to a tile script 0 Answers
2D character Animation-controller 1 Answer