- Home /
Gizmos drawing units
Hello world!
I'm trying to implement explosions that affect areas. In the editor I'm trying to visualize the blast radius of the prop by using
public void OnDrawGizmosSelected() { if (Data != null) Gizmos.DrawWireSphere(GetComponent ().bounds.center, Data.BlastRadius); }(Disregard
Data
, it's just a
ScriptableObject
)
If I set up the BlastRadius to say 4f
what I get in the editor is:
When I run the game, the "final blast radius", I get, is this:
As you see, the actual collider added by script (the green one) is quite bigger than what it should have been. As long as it concerns the white gizmo drawn.
Am I missing something between Gizmo units and actual scene units?
Thanks :)
How do you set the radius of the collider ?
If you scale it using Data.BlastRadius, it's absolutely normal that it doesn't fit with the radius of the gizmo.
The radius of the collider is set with collider.radius
and there is no scaling whatsoever being done. I checked the final collider radius and it's nearly 4f (+ precision error)
private IEnumerator explode() { while (collider.radius < Data.BlastRadius) { collider.radius += Data.BlastRadius * Data.BlastPeakTime * Time.deltaTime; yield return new WaitForEndOfFrame(); } }
Answer by Hellium · Sep 16, 2015 at 01:12 PM
And how about the scale of the object and its parentS ? Are you sure all are set to ( 1, 1, 1 ) ?
Crap! Scaling was the problem. Please post an answer so I can accept it. Thanks a lot for the effort.
Your answer
Follow this Question
Related Questions
Gizmo disappeared when custom editor 0 Answers
Gizmo equivalent of Handles.DrawSolidArc? 0 Answers
Accessing Unity 3.4 gizmos through code. 1 Answer
Custom inspector draw Gizmos 0 Answers
How to hide Gizmos by script 4 Answers