Search Unity

Measure/calculate speed, distance and time between start and end point

Discussion in 'Physics' started by shax13377, Dec 12, 2018.

  1. shax13377

    shax13377

    Joined:
    Dec 12, 2018
    Posts:
    3
    Hi guys,

    I have problems in scripting with unity 3D (VR HTC VIVE)

    We have a project in our class where we have to simulate a welding process.

    For our welding process we created a welding pistol. For moving the pistol we are using ->(HTC Vive Controller).

    After we push the controller button at the (Start Point) the time should run and then we move the welding pistol from (Start Point) to (End Point). In between those two points (start - end) I would like measure actual speed(velocity), delta time and delta distance.

    I added my script and a picture below

    Iam happy if I get some answers


    Thanks you

    Best regards

    Seb
     

    Attached Files:

  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,405
    for timer, when welding begins, set mytimer = 0 and start incrementing timer float:
    Code (CSharp):
    1. mytimer+=Time.deltaTime;
     
  3. shax13377

    shax13377

    Joined:
    Dec 12, 2018
    Posts:
    3
    Hi mgear,

    I tried ur way and it didn’t work :(

    float timer = 0;

    In void update:

    timer += Time.deltaTime;

    ? Is there a difference between mytimer and timer?

    best regards
     
  4. shax13377

    shax13377

    Joined:
    Dec 12, 2018
    Posts:
    3
    The timer is working ;)

    But how can I calculate the actual speed and the delta distance at any point?

    Iam happy for an answer

    Best regards