Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by longbowgr · Sep 16, 2015 at 02:17 PM · gizmosgizmo

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: alt text

When I run the game, the "final blast radius", I get, is this: alt text

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 :)

capture.png (405.8 kB)
capture1.png (259.6 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Sep 16, 2015 at 12:57 PM 0
Share

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.

avatar image longbowgr Hellium · Sep 16, 2015 at 01:02 PM 0
Share

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();
    }
}

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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 ) ?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image longbowgr · Sep 16, 2015 at 01:15 PM 0
Share

Crap! Scaling was the problem. Please post an answer so I can accept it. Thanks a lot for the effort.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges