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 /
avatar image
0
Question by jack_sparrow · Jul 02, 2012 at 08:22 AM · forceballkinect

add force in ball when i kick the ball

hey friends

need some help here. i have character which i control by kinect and when i kick the ball it goes well but i want to add some force in ball but in the direction of ball is kicked

i have script but it only Add force in forward direction.

here's the script i m using.


 var speed: int = 100;
 
 function OnControllerColliderHit(hit:ControllerColliderHit){
 if(hit.gameObject.tag == "ball"){
     Debug.Log("We hit a object");
 hit.rigidbody.AddForce(Vector3.forward * speed);
 }
 }

thanx cheers

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 Tim-Michels · Jul 03, 2012 at 06:30 AM 0
Share

Well, I should have more info before I can help you further. You should at least give me some of your code and explain how your scene is setup to get a more specific explanation.

avatar image przem997 · Aug 17, 2013 at 09:50 AM 0
Share

hello, I need it too...

can somebady help?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Tim-Michels · Jul 02, 2012 at 08:38 AM

Well you should calculate a Vector3 for your direction. You should calculate it something like this:

Pseudo-code

Vector3 shootDir = ballPosition - footPosition; //calculate delta vector

shootDir.Normalize(); //normalize

ball.AddForce(shootDir * speed, ForceMode.Impulse); //Add impulse force in correct direction.

Hope this helps ;)

Cheers

Comment
Add comment · Show 3 · 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 jack_sparrow · Jul 03, 2012 at 06:06 AM 0
Share

@Tim $$anonymous$$ichels Thanx for reply,

i don't know how to comment under your answers bcoz of new UI of uinty answers. that's why replying here.

i m confused about how to get ball position and foot position i m noob in coding. i don't have much knowledge about scirpting.

thanx cheers

avatar image przem997 · Aug 20, 2013 at 09:11 AM 0
Share

thanks for reply. it works fine.

in my project 1mass 500-2000 is to high, 90-150 is max.

avatar image Linus · Aug 20, 2013 at 09:13 AM 0
Share

@przem997 Converted your answer to a comment. Please use the Add comment link listed under each answer when posting a comment in the future. Sorry if I placed it under the wrong answer.

avatar image
0

Answer by robertbu · Aug 17, 2013 at 02:43 PM

Try:

 hit.rigidbody.AddForce(hit.moveDirection * kickPower);

For an object with a mass of 1.0, kickPower will need to be fairly large...in the range of 500 - 2000.

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

7 People are following this question.

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

Related Questions

[Solved] How to shoot an object in front of the player? 1 Answer

How to make Sphere to jump? 2 Answers

Using character controller insted of normal collider 0 Answers

Add Force: Increase Speed of Ball periodically 3 Answers

Help with player movement and adding force to a ball. 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