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 nikhil38 · Feb 02, 2013 at 10:28 AM · slowmotion

slow motion effect in game

I want to create a slow motion effect in my game . I have used

      time.timescale = (0 < somevalue <1) ;

but this is effecting my entire scene....i want everything in my scene should go slow except my player object ... Hlink textelp me with this !!!

playerscript.txt (3.0 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Doireth · Feb 02, 2013 at 12:21 PM

While I don't know for sure one way you could do it is multiply player's move speed by

 var val : float = 1 / Time.timeScale;

That would increase the movement speed by the difference in the time scale. For example, if the time scale was 0.1 (slow motion) then the player's speed would need to be 10 times faster which would compensate for the difference.

Here's an example (it's written in C# but that it's only to serve as an example)

Normal version

 public class TestSlowMo : MonoBehaviour {
     private Vector3 originalPos;
     // Use this for initialization
     void Start () {
         originalPos = transform.position;
     }

     // Update is called once per frame
     void Update () {
         Vector3 newPos = originalPos;
         
         newPos.x += Mathf.PingPong((Time.time * 10), 10);
         
         transform.position = newPos;
     }
 }


Time-scale compensating version:

 public class TestSlowMo : MonoBehaviour {
     private Vector3 originalPos;
     // Use this for initialization
     void Start () {
         originalPos = transform.position;
         Time.timeScale = 0.01f;
     }
     private float _val;
     // Update is called once per frame
     void Update () {
         _val = (1 / Time.timeScale);
         Vector3 newPos = originalPos;
         
         newPos.x += Mathf.PingPong((Time.time * 10) * _val, 10);
         
         transform.position = newPos;
     }
 }

This could be time consuming (sorry I couldn't resist the pun) way to implement the desired effect but it seemed to work well on my test.

Comment
Add comment · Show 4 · 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 nikhil38 · Feb 03, 2013 at 09:40 AM 0
Share

hey thanks mate.... i tried ..but seems things are just not working....i am getting very jerky motions

avatar image Doireth · Feb 03, 2013 at 09:51 AM 0
Share

$$anonymous$$y answer requires a lot to integrate it into a full project. Any value that gets incremented over time should be adjusted like in my solution. I have my tested answer and it works perfectly.

There is no easy way to achieve what you are trying to do.

avatar image nikhil38 · Feb 03, 2013 at 10:23 AM 0
Share

i guess what i'm trying to implement is similar to $$anonymous$$ax Payne's bullet time effect ...is it mate ....? how should i go forward on this from now ?

avatar image Doireth · Feb 03, 2013 at 10:53 AM 0
Share

The code I posted could create such an effect but like I said it won't be easy. Experiment with this but be prepared to spend some time to get the desired result. Applying the timescale compensating value like above to each movement value of the player will allow the player to move at normal speed regardless of timescale.

avatar image
0

Answer by AyJayKaySoft · Feb 02, 2013 at 12:26 PM

 if (Time.timeScale > 0 && onSlowMotion) {
     htranslation /= Time.timeScale;
     vtranslation /= Time.timeScale;
 }

but with this your character will slow down if timeScale > 1 (so, you could add ( && Time.timeScale < 1) to the if statement, if you want do that). This should work, if timeScale influences deltaTime like I think.... could you write if it works?

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 AyJayKaySoft · Feb 02, 2013 at 12:28 PM 0
Share

I am 6 $$anonymous$$ to late :D

avatar image nikhil38 · Feb 03, 2013 at 09:01 AM 0
Share

thanks for the reply dude....but it didn't work !!!

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

11 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

Related Questions

A node in a childnode? 1 Answer

ScrollView: scroll bar on left side instead of right? 1 Answer

Mono Can't Attach to unity ( for debug ) 2 Answers

Issues with Render Texture 1 Answer

Texture from blender only corners showing 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