Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
  • Help Room /
avatar image
0
Question by chetan312 · Jul 02, 2020 at 12:35 PM · addexplosionforce

addExplosionforce is not working properl;y

hii, I am using AddExlosionForce for a bomb explosion but the effect of explosion is very little even i change explosion power from 30 to 30k...any idea, what i am doin wrong? thanks.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TestingExplosiveforce : MonoBehaviour
 {
     public float radius = 20.0F;
     public float power = 30000.0F;
 
     void Start()
     {
         Vector3 explosionPos = transform.position;
         Collider[] colliders = Physics.OverlapSphere(explosionPos, radius);
         foreach (Collider hit in colliders)
         {
             Rigidbody rb = hit.GetComponent<Rigidbody>();
             Debug.Log("testing hit colliders" + hit.gameObject.name);
 
             if (rb != null)
                 rb.AddExplosionForce(power, explosionPos, radius, 4.0F);
         }
     }
 }




Comment
Add comment · Show 3
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 · Jul 02, 2020 at 12:42 PM 1
Share

Where do you change the value? In the editor, not in the public float power = 30000.0F right?

avatar image chetan312 Hellium · Jul 02, 2020 at 12:58 PM 0
Share

thanks for your response, actually u are right , i totally forgot to change in the Editor, but same problem occur in my original grenade Script and i dont use Public field there ....

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class bazookaBulletFunctionality : $$anonymous$$onoBehaviour
 {
     private Rigidbody rb;
     private int radius=10;
     private float power = 1000;
  
     // Start is called before the first frame update
     void Start()
     {
         rb = GetComponent<Rigidbody>();
         rb.AddForce(transform.forward*2500f);
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 
     private void OnCollisionEnter(Collision collision)
     {
 
         Explode();
 
     }
     private void Explode() {
 
         Vector3 ExplosionPos = transform.position;
         Collider[] colliders = Physics.OverlapSphere(ExplosionPos, radius);
 
         foreach (Collider hit in colliders)
         {
             Rigidbody rb = GetComponent<Rigidbody>();
             Debug.Log("hit object here with name" +hit.gameObject.name);
             
                 rb.AddExplosionForce(power, ExplosionPos, radius, 3);
 
            
 
         }
         Destroy(gameObject);
 
     }
 }
 

avatar image chetan312 chetan312 · Jul 02, 2020 at 01:52 PM 0
Share

okay, i think i found my mistake ...in Foreach loop I just used getComponent() ins$$anonymous$$d of hit.GetComponent()...Thanks

0 Replies

· Add your reply
  • Sort: 

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

202 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to create a generic script for bouncing behaviour 1 Answer

Getting an array of Rigidbodies 1 Answer

AddExplosionForce help? 0 Answers

Why isn't AddExplosionForce working? 1 Answer

Why do my objects floating constantly using AddExplosionForce? 1 Answer


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