Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Inconsistent Launch Speeds/Force when Spawning Badminton Birdies

Discussion in 'VR' started by mjmui, Jul 18, 2023.

  1. mjmui

    mjmui

    Joined:
    Jun 21, 2023
    Posts:
    2
    Hi, I was wondering if anyone has some tips when dealing with Time.timeScale? I'm working on a personal project and it's a badminton shot training VR program. The idea is to train certain shots in badminton, such as nets, drives, clears, lifts, smashes, etc. and the key point is that this environment should be able to slow down time for a birdie to make it easier to adjust yourself as the user/player and hit the bird. This theoretically should allow for the user/player to have the time needed to work on his/her form. When ready, the player can then bring the simulation into normal speed to train.

    In terms of implementation currently, basically, there's a spawner that launches birdies using AddForce in the spawner's script (this script uses Update() and calls AddForce once every time the current time MOD some constant == 0). The birdie's themselves have their own script, meant for the physics behind the birdies. However, the script for the birds has global variables, a boolean for if I want to slow down time for the birdies to make them travel slower, and a float for how much I want to affect the Time.timeScale by to make the birdies slower. There is a "model" bird in the simulation that just sits there, and my spawner makes clones of said model bird so that any time scaling settings I set on it, the birds that do get spawned for the user take on those attributes (such as should this bird be slowed down, at regular speed, etc.)

    I currently I'm struggling with a strange issue, where in my code for the spawner, I have AddForce(transfom.up * (750 / Time.timeScale, let's say 0.5 right now)). Normally, I know this means to double the force, since I'm dividing 750 by 1/2 essentially. Strangely enough though, when I connect the VR set (Vive Pro from HTC), the birds don't travel as far as the math suggests. I suspect its a frame rate issue since when VR isn't connected, my FPS is around 100s+, but after I connect VR, it drops to 40s-90s which makes the increased force from dividing 750 by 1/2 (if I set the simulation to send birds at the user at "slow" speed) send the bird to the same location as when I just do AddForce(transform.up * 750) at normal speed. Any tips? I appreciate any help! Thanks.

    Unity Version: 2022.3.2f1
     
    Last edited: Jul 18, 2023
  2. mjmui

    mjmui

    Joined:
    Jun 21, 2023
    Posts:
    2
    I tried messing with the environment's gravitational constant and I found out that making the timeScale = 0.5f, I needed to have 1/4 of -9.8 to get the same distance. Any thoughts though?