Speed beetween two vectors

Hi there, I need to calculate speed between two points with a certain time. I have vector(start position) and second vector(that player controls). Sometimes second vector can speed up. After 10 sec second vector will stop. I need to get his speed he had in the movement. Any ideas how can I solve this? Thanks

speed = distance/time :slight_smile:

The speed is the finalVector - startVector all divided by the time. So:

float speed = ((endVector - startVector) / 10).magnitude;

EDIT: At least I think that’s what you’re asking… not so sure reading it back :confused:

Easy all you need to do is get the first position then the position in 10 seconds and subtract those.

Here is an example in JS

var FirstPos : float;
var LastPos : float;
var speed : float;

var time : float;

function Start () { //If you don't want to measure it from the //start then just do an if statement in function Update

FirstPos = transform.position.y; // Or any other axis


function  Update () {

if(time < 10) {
LastPos = transform.position.y;
speed = FirstPos - LastPos;