Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity how to add force

public Rigidbody rb;

if(Input.GetKey(KeyCode.W))
{
	rb.AddForce(100, 0, 0);
}  
Comment

how to add a force to an object unity

private Rigidbody2D rb;
public Vector2 direction;
public float force;

void Start()
{
	rb = GetComponent<Rigidbody2D>();
    rb.AddForce(direction * force, ForceMode2D.Impulse);
    //rb.AddForce(--pass in Vector--, --can pass in ForceMode--);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity time.deltatime timescale 0 
Csharp :: windows form textbox numbers only 
Csharp :: .net create ienumerable of strings 
Csharp :: subtract two times c# 
Csharp :: c# boiler code shortcut 
Csharp :: unity get scene index 
Csharp :: Unity Rotate around the real center 
Csharp :: executable path with app name c# 
Csharp :: c# download file 
Csharp :: Unity Scene Load by Name 
Csharp :: unity find closest point on line 
Csharp :: how to store more data than doublec# 
Csharp :: making beep voice in c# 
Csharp :: c# find index element array 
Csharp :: how to make a quit button in unity 
Csharp :: how to open any file on button click in winforms 
Csharp :: validate base64 string c# 
Csharp :: system.linq.iorderedenumerable`2[system.char,system.char] çözümü 
Csharp :: How do I remove all non alphanumeric characters from a string? 
Csharp :: stop sound in unity 
Csharp :: no move arrows unity 
Csharp :: Generate UUID in c# 
Csharp :: c# fizzbuzz 
Csharp :: coroutine not eaffected by time.timescale unity 
Csharp :: how to delay between lines in unity 
Csharp :: c# implicit operator 
Csharp :: c# read from file 
Csharp :: unity detect any key 
Csharp :: c# round number 
Csharp :: generate random string c# 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =