playMaker

Author Topic: How to get another object's speed for a gameobject?  (Read 932 times)

Artoo

  • Playmaker Newbie
  • *
  • Posts: 28
    • View Profile
How to get another object's speed for a gameobject?
« on: April 08, 2018, 10:47:54 AM »
Hello,
I'm making a racing game, and I would need a car to get the relative speed of another car in front of it, to determine if it should keep drafting behind it or overtake/avoid slower or stationary cars.

I tried this with a raycast from the front of the car and storing the hit object, but I only get 0m/s from that.

Can anyone help how to properly do this?

CookiMonster

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How to get another object's speed for a gameobject?
« Reply #1 on: April 08, 2018, 12:24:52 PM »
Relativ speed is the difference of leading car speed and following car speed. To get the the speed use "get velocity" or do a simple math.