• 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 nantoaqui · Jun 11, 2018 at 09:14 PM · gravitytimescaleslowmotion

Scaling gravity by Time.timeScale

Hello,

I'm trying to achieve the QuickSilver effect from X Men Days Of the Future Past, whereas the whole game stays in slow motion and the character moves at normal speed.

Everything is working fine for the character:

 float framesPerSecond = 60f;
 float scaleVelocity = 1f / Time.timeScale;
 character.velocity = new Vector2(velocity.x * framesPerSecond * Time.fixedDeltaTime * scaleVelocity, velocity.y * framesPerSecond * Time.fixedDeltaTime * scaleVelocity);
 character.gravity = 1f * Time.fixedDeltaTime * scaleVelocity

The code above makes possible for the character to run freely while in slow motion.

The problem comes to affected objects by slow motion that has force applied to it. e.g: An enemy jumping in slow motion would stop jumping higher because the time was scaled down.

I was trying to fix this by using this code, but the enemy only jumps half of the way.

 enemy.gravity = (1f * Time.fixedDeltaTime) / scaleVelocity;

In the code above i'm scaling the gravity down, because I want to make the force to be applied as if it was in normal mode, but it is not working.

I tried to manipulate gravity's value manually and it seems to have this relation:

 timeScale = 0.5
 gravity ≈ 0.7
 
 ===
 
 timeScale = 0.1
 gravity ≈ 0.5

Any thoughts of how to solve this?

Thanks!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

145 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

Related Questions

Change Time.scale only on specific objects 1 Answer

Timescale Pause Combined with Animated UI 1 Answer

Load scene after time 1 Answer

is it possible to make a non kinematic object using gravity change to kinematic when it hits a trigger? 1 Answer

Object rotates normaly while moving, then does zig zags? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges