Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
0
Question by Borzi · Sep 03, 2013 at 02:57 PM · raycastvector3addforceforcehit.point

AddForce to the Left?

For some reason my GameObject keeps getting knocked to the right instead of to the front and thats why I wanted to know if I could add force to the left? I am using this line:

 Hit.rigidbody.AddForceAtPosition(transform.forward * Force , Hit.point);
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 Sasstraliss · Sep 04, 2013 at 02:21 AM 0
Share

Have you looked into using local space?

avatar image Borzi · Sep 04, 2013 at 01:05 PM 0
Share

Hmmm...what does that mean?

avatar image toddisarockstar · Apr 23, 2017 at 01:50 PM 0
Share

[https://docs.unity3d.com/ScriptReference/Rigidbody.AddExplosionForce.html][1]

look at this [1]: https://docs.unity3d.com/ScriptReference/Rigidbody.AddExplosionForce.html

3 Replies

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

Answer by Borzi · Sep 04, 2013 at 05:01 PM

Okay so this is what I did, I it seems like this just works out perfectly and is a simple solution :)

 if(Hit.collider.rigidbody)
         {
         //Make the object fly away by adding force to it
         Hit.rigidbody.AddForceAtPosition(Force * FirePoint.transform.forward, Hit.transform.position);
         //Check if it hit and Object
         Debug.Log("Added Force to Rigid Body");
         }

Just wanted to post this in case anyone else had a similar problem.

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
1

Answer by MarwanElghitany79 · Apr 23, 2017 at 01:45 PM

 player.AddForce( Vector3.left * speed );
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 meat5000 · Sep 04, 2013 at 02:30 AM

AddForceAtPosition adds rotation, maybe that's why it seems to go the wrong way. Either that or your models axes are misaligned.

Try AddRelativeForce

 rigidbody.AddRelativeForce (-1, 0, 0); // 1 Unit left in local axes

Comment
Add comment · Show 2 · 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 Borzi · Sep 04, 2013 at 01:09 PM 0
Share

Well its a sphere, so the objects rotation could hardly be misaligned or what do you mean? And how would you implement AddRelativeForce. As a separate line I suppose?

avatar image meat5000 ♦ · Sep 04, 2013 at 03:03 PM 0
Share

Just because it's a sphere it doesn't mean it doesn't have axes or a relative direction. AddRelativeForce is implemented in the same way, just the Vector3 is in local space...that's coordinates relative to the object not relative to the world.

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

20 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

Related Questions

GameObject facing hit.point doesn't always work 1 Answer

How to find an object directly above another w/out Raycast? 1 Answer

How to get Vector3 of force that WILL BE applied to Rigidbody with AddForce()? 0 Answers

Moving gameobject along terrain based on player movement using raycast 1 Answer

Adding rotation to Physics.AddForce(); ... Getting weird error? 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