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 raptorkwok · Feb 06, 2014 at 03:55 AM · c#rigidbodyaddforceitweenitweenpath

Combine iTween with physics acceleration

I am trying to combine iTween with physics acceleration.

top view of the path

Here is the top view of the path. The brown rectangle is made by a cube GameObject, with an iTweenPath component attached (4 nodes). The path is named Path1. On the left, there is a sphere (may not be seen clearly), which acts as the Actor, with RigidBody attached (mass = 3), was put few units above the floor.

Then, I assigned a script to the Actor, which is:

 void OnCollisionEnter(Collision collison) {
   iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("Path1"), "time", 5));
 }

when the ball hits the ground due to gravity, it triggers the iTween.MoveTo(). The above works as expected.

However, I want to combine with my physics acceleration script, which is:

 void FixedUpdate() {
   rigidbody.AddForce(transform.forward * 5.0f, ForceMode.Acceleration);
 }

However, iTween governs the movement, made the AddForce() in FixedUpdate() no effect at all. How can I combine these two?

Comment
Add comment · Show 4
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 robertbu · Feb 06, 2014 at 04:03 AM 0
Share

It is unclear to me in what way you want to combine the two. I'm going to assume you want to move along the path but at a rate expected by the rigidbody.AddForce() rather than a fixed time. And it is unclear to me what happens when you end up at the end of the path.

I'm going to suggest you explore iTween.PutOnPath() and iTween.PointOnPath(). You may have to simulate the applying of force, but these two give you the control to put the point at a specific percentage along the path.

avatar image raptorkwok · Feb 06, 2014 at 04:27 AM 0
Share

Yes, I want to use the dynamic speed given by rigidbody.AddForce() rather than fixed time. So, you mean that the physics cannot be merged with iTween, and I have to calculate the speed by myself from time to time?

avatar image robertbu · Feb 06, 2014 at 04:56 AM 1
Share

"So, you mean that the physics cannot be merged with iTween, and I have to calculate the speed by myself from time to time?"

"cannot" is a strong word, but you would have to jump through some hoops. For example you could calculate at each fixed update how far the object as traveled since the last update, calculate what percentage that distance is along the path, then use iTween.PutOnPath() to put the object at that percentage. This is untested territory for me, so it is just a theory. But I expect that you will get a better result by not using a Rigidbody for this calculation and doing the math on your own based on percentage rather than distance.

avatar image raptorkwok · Feb 06, 2014 at 07:13 AM 0
Share

that's a nice suggestion. I will do some tests on your theory.

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

17 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

Related Questions

how get bow to add more force over time 0 Answers

Jumping with rigid body3d 1 Answer

Consistent AddForce distance/direction 2 Answers

Distribute terrain in zones 3 Answers

Why wont my character jump? (using rigidbody and addForce) 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