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 rigid body variable 
Csharp :: random mac address c# 
Csharp :: bsod screen c# 
Csharp :: mvc refresh page from controller 
Csharp :: replace first occurrence of character in string c# 
Csharp :: c# itext 7 PdfDocument from byte array 
Csharp :: c# datagridview hide header 
Csharp :: unity game object remove parent 
Csharp :: combobox selected name c# 
Csharp :: set margin programmatically wpf c# 
Csharp :: interpolate rotation unity3d 
Csharp :: dataannotations datetime range 
Csharp :: c# read double 
Csharp :: how to close another app in system with c# 
Csharp :: unity switch to scene and transfer data 
Csharp :: c# color to console color 
Csharp :: c# arrow 
Csharp :: c# convert double to string 
Csharp :: unity list get item at index 
Csharp :: sum the digits in c# 
Csharp :: string c# 
Csharp :: how to fix on Input.GetMouseButtonDown(0) conting as ui 
Csharp :: c# get a value from value tuple list 
Csharp :: join dictionaries keys c# 
Csharp :: audio unity 
Csharp :: c# create class from parent class 
Csharp :: how to update model in entity framework db first approach 
Csharp :: c# centos Regex Username 
Csharp :: how to find the text position in excel in c# 
Csharp :: verifyusertokenasync password reset token 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =