Answers for "Check if GameObject is within the volume of a cone."http://answers.unity.com/questions/732691/check-if-gameobject-is-within-the-volume-of-a-cone.html
The latest answers for the question "Check if GameObject is within the volume of a cone."Answer by robertbuhttp://answers.unity.com/answers/732748/view.html
The typical solution to the problem is to put a collider on object like switches and raycast against colliders on these objects. When the player's raycast hits a collider of a particular type, the code tells the object, and the object does whatever it is programmed for. If you want to detect in a cone fashion as you've asked:
- 'player' is the transform of the player
- 'object' is the transform of the object being tested
- 'r' is the radius of the code
- 'look 'is a direction vector of the center of the reticle. If you are constructing a ray from the mouse position, it will be the Ray.direction.
---
var v = object.positon - player.position;
var maxAngle = Mathf.ATan(r / v.magnitude) * Mathf.Rad2Deg;
if (Vector3.Angle(look, v) <= maxAngle) {
Debug.Log("Trigger object");
}Sun, 22 Jun 2014 16:49:10 GMTrobertbuAnswer by meat5000http://answers.unity.com/answers/732746/view.html
My answer disappeared! :D
Anyway, I'll write again.
Try [SphereCast][1]
Its a fat Raycast
[1]: http://docs.unity3d.com/ScriptReference/Physics.SphereCast.htmlSun, 22 Jun 2014 16:44:36 GMTmeat5000