Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 yusufgunay · Sep 16, 2020 at 07:59 PM · instantiateaddforceslowmotion

Addforce function for an Instantiated object is not working after slow motion effect!

I have a code block like below,

Basically I am trying to instantiate an object(asteroid) and add force to it. Everything works very fine. But in another script I detect the collision and I gave slow motion effect for four seconds. But after slow motion effect happens, the objects are still instantiated yet the addforce is not working anymore. The objects holds on air.

I really dont know what is the problem!

Instantiate code++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public Rigidbody asOne;

 public float AsShootPower = 50f;

 public Transform AsteroidPos;

 Vector3 offset;
 public float astCount = 100f;

 void Start()
 {
     Invoke("StartRain", 2);
 }

 private void StartRain()
 {
     StartCoroutine(countDown());
 }

 IEnumerator countDown()
 {
     while (astCount > 0)
     {
         offset = new Vector3(Random.Range(-15,15), Random.Range(-1, 1), Random.Range(-15, 15));
         Vector3 randomPosition = AsteroidPos.transform.position + offset;
         Rigidbody newAst;
         newAst = Instantiate(asOne, randomPosition, AsteroidPos.rotation);
         newAst.GetComponent<Rigidbody>().AddForce(AsteroidPos.forward * -AsShootPower);
         yield return new WaitForSeconds(Random.Range(0,2));

         astCount--;
     }

 }

slowmo code +++++++++++++++++++++++++++++++

 public float SlowdownFactor = 0.05f;
 public float SlowdownLength = 4f;

 // Update is called once per frame
 void Update()
 {
     Time.timeScale += (1f / SlowdownLength) * Time.unscaledDeltaTime;
     Time.timeScale = Mathf.Clamp(Time.timeScale, 0f, 1f);
 }


 public void DoSLowMotion() 
 {
     Time.timeScale = SlowdownFactor;
     Time.fixedDeltaTime = Time.timeScale * .02f;
 }

Slowmo Detector++++++++++++++

 public TimeManager timeManager;

 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Asteroid")
     {
         Debug.Log("Asteroid is coming!!");
         timeManager.DoSLowMotion();

     }
 }

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

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

166 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 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

Instantiated Bullet Force not being applied 0 Answers

How can you instantiate a prefab with an initial burst of speed using ForceMode2D.Impulse? 2 Answers

create a cannon ball based on cannon angles and cannon power 0 Answers

Add force to instantiated prefabs (c#) 0 Answers

Help! My projectile just falls to the ground :( 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