Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Dreaa · Feb 22, 2018 at 09:26 PM · rigidbodyawakesleep

Rigidbody won't awake

Hello,

I'm working on a project where I launch a ball with an AddForce, everything works well there.

Here is the script for that part :

 void ThrowEntity()
     {
         GM.loadingRing.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
         GM.rebondMax = (int)GM.powerRay / GM.rebondTimerDiviser;
         GM.timerMax = (int)GM.powerRay / GM.rebondTimerDiviser;
         if (GM.rebondMax < 1 || GM.timerMax < 1)
         {
             GM.rebondMax = GM.rebondMin;
             GM.timerMax = GM.timerMin;
         }
 
         GM.rebondActual = GM.rebondMax;
         GM.timerActual = GM.timerMax;
 
         // Si on possède l'entité et qu'on relache le clic gauche, l'entité ne dépend plus du personnage et est propulsée vers l'endroit où l'on regarde à une force dépendant du temps d'appui du clic gauche
         Ray rayon = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hitInfo;
         if (Physics.Raycast(rayon, out hitInfo))
         {
             GM.carrying = false;
             GM.entity.transform.parent = null;
             GM.entity.GetComponent<Rigidbody>().isKinematic = false;
             GM.entity.GetComponent<Rigidbody>().AddForce(rayon.direction * GM.powerRay);
             GM.trail.Play();
         }
 
         // On définit également la durée de vie de la trail en fonction de cette force
         GM.trail_lifetime = GM.trailLifetimeMax * GM.powerRay / GM.powerThrowEntityMax;
         GM.powerRay = 0;
     }

The problem comes with a new mechanics I just added : - I slow mo the game and when I release the mouse click it change the direction by a new addForce. Here it works again. There is the code :

     void SlowMotion()
     {
         if (Input.GetMouseButton(0)) 
         {
             Ray rayon = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hitInfo;
             if (Physics.Raycast(rayon, out hitInfo))
             {
                 GM.entity.GetComponent<Rigidbody>().AddForce(rayon.direction * GM.ForceSlowMo, ForceMode.Impulse);
             }
                 
         }
         Time.timeScale = GM.slowMoTimeScale;
         Time.fixedDeltaTime = Time.timeScale * .02f; 
 
     }

The problem comes after. When I pick up the ball after using the slow motion, my rigidbody goes to sleep, so if I want to launch it again the addforce just doesn't work because of that. And the problem is, i can't wake up this rigidbody for an unknown reason.

I've tried : - WakeUp() : in update, at the start of the stack (to determine the force) and right before the launch. - Tweaking the project settings and the treshold for sleeping rigidbody by putting it at 0 - doing a "entity.transform.position = entity.transform.position"

And noone of these solutions i've found on the net is working, i'm starting to being desperate.

Greetings and thanks for your help, also sorry for bad english.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dreaa · Mar 09, 2018 at 09:49 AM

Btw if anyone has this kind of problem i've found the solution by searching a bit more : You have to set your "interpolate" into rigidbody's inspector to interpolate or extrapolate.

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

150 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

Related Questions

How to make the sphere not fall out of the cylinder 0 Answers

How to make an objects mass increase the longer its air born? 1 Answer

Question on Peaper.Io ? 0 Answers

rigidbody.AddForce doesn´t work in c# 1 Answer

How to prevent AddForce from stacking up ? 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