Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity get speed of object

public float speed;
public float speedPerSecond;
public Vector3 oldPosition;

void Update()
 {
     speed = Vector3.Distance(oldPosition, transform.position); //This is the speed per frames
  	 speedPerSecond = Vector3.Distance(oldPosition, transform.position) / Time.deltaTime; //This is the speed per second
     oldPosition = transform.position;
     Debug.Log("Speed: " + speed.ToString("F2"));
 }
Comment

PREVIOUS NEXT
Code Example
Csharp :: ping with c# 
Csharp :: c# set a guid 
Csharp :: laravel route redirect 
Csharp :: unity or 
Csharp :: unity pause animator 
Csharp :: c# string to double 
Csharp :: resize image c# 
Csharp :: easily start admin process from service c# 
Csharp :: c# mysql query 
Csharp :: openfiledialog c# 
Csharp :: random value in array c# 
Csharp :: unity disable cursor 
Csharp :: c# format decimal as currency 
Csharp :: wpf choose file dialog 
Csharp :: c# take first 4 characters of string 
Csharp :: unity know when gameobject presed 
Csharp :: require admin pervillages c# 
Csharp :: double to int c# 
Csharp :: c# add to start of list 
Csharp :: unity c# reference link url 
Csharp :: c# system.drawing.color to system.windows.media.color 
Csharp :: how to unset passwordchar in c# windows application 
Csharp :: restart wpf application 
Csharp :: how to say "Hello world" in c# 
Csharp :: xamarin overlay 
Csharp :: asp.net throw unauthorized exception 
Csharp :: unity2d click on gameobject 
Csharp :: c# loop 
Csharp :: ++ operator c# 
Csharp :: cshtml foreach 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =