Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 zimmer550 · Oct 09, 2016 at 10:02 PM · unity 5rigidbody.addforcerigidbody physicsexplosionsrockets

Horizontal push back not the same as vertical pushback whenever I use add explosion force

I'm coding rocket jumping in an FPS game. Whenever I shoot directly beneath me, I get the proper push-back in the vertical axis. However, when I shoot at something directly in front of me, I don't get the same push back in the horizontal axis as I did in the vertical axis. The push back in the horizontal axis is significantly lower as compared to one in the vertical axis. Here's a video of what I'm experiencing at the moment https://www.youtube.com/watch?v=gh4_rPnI1wI

The code I use for my explosion is below:

 using UnityEngine;
 using System.Collections;
 
 public class explosion : MonoBehaviour {
     public float explosiveForce = 20f;
     public float explosiveRadius = 5f;
     public float upwardsForce = 5f;
 
     private Collider[] hitColliders;
 
     void Update() {
         hitColliders = Physics.OverlapSphere (transform.position, explosiveRadius);
         foreach (Collider hit in hitColliders) {
             Rigidbody rb = hit.GetComponent<Rigidbody> ();
 
             if (rb != null) {
                 print ((hit.transform.position - transform.position).normalized);
                 print ((hit.transform.position - transform.position).normalized * explosiveForce);
 //                rb.AddExplosionForce(explosiveForce, transform.position, explosiveRadius, upwardsForce, ForceMode.Impulse);
                 rb.AddForce((hit.transform.position - transform.position).normalized * explosiveForce, ForceMode.Force);
             }
         }
     }
 }

I've commented out add explosion for now and am using add force as described. However, I'm still not getting the result I want.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Geometrical · Oct 10, 2016 at 02:09 AM

Nothing is actually wrong with your code, it's just how physics works. Simply put, when you fire a rocket vertically you create a force that opposes gravity; and when you fire horizontally both the force you create is acting on you, as well as the full, unopposed force of gravity which is pulling you down.

Try detecting which objects might create the horizontal force and apply a special modifier to the force you're creating to increase the horizontal push-back. If this is too vague for you just let me know and I'll try to explain in a better way.

Comment
Add comment · 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
0

Answer by zimmer550 · Oct 10, 2016 at 09:32 AM

Could it have anything to do with me modifying the rigidbody velocity directly in my player movement script. Another unity user said I should not modify velocity directly but simply add force to the player in the movement script. I'll try with that and then post my results

Comment
Add comment · 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

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

116 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

Related Questions

Hello guys, why i can not add this to my code? 1 Answer

Rigidbody goes through an object 1 Answer

Rigidbody Addforce Not Working 1 Answer

Avoid varying output on same amount of force applied to a Rigidbody2D. 0 Answers

Conserve some of Rigidbody's speed when turning. 0 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