Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to set rigidbody velocity in unity

//Set Velocity to a certain speed
[SerializeField] private float maxSpeed = 10;
[SerializeField] private Rigidbody rb;

void FixedUpdate() {
  if(rb.velocity.magnitude > maxSpeed) {
    rb.velocity = rb.velocity.normalized * maxSpeed;
  }
}
Comment

unity how to set rigidbody velocity

Vector3 velocity = new Vector3(10f/*x*/, 10f/*y*/, 10f/*z*/);
GetComponent<Rigidbody>().velocity = velocity;
Comment

rigidbody velocity c# unity

//for rigidbody2D
GetComponent<Rigidbody2D>().velocity =new Vector2(40,0);
Comment

unity control velocity on rigidbody

[SerializeField] private Rigidbody rb;
[SerializeField] private float rbMaxSpeed;
[SerializeField] private float rbMag;

private void FixedUpdate()
{
	rbMag = rb.velocity.magnitude; // Total xyz magnitude
    if (rb.velocity.magnitude > rbMaxSpeed)
    {
    	rb.velocity = Vector3.ClampMagnitude((Vector3)rb.velocity,rbMaxSpeed);
    }
}
Comment

rigidbody velocity

rb.velocity = new Vector3(0, 10, 0);
Comment

PREVIOUS NEXT
Code Example
Csharp :: convert string to jtoken c# 
Csharp :: Customize yup number 
Csharp :: unity interfaces 
Csharp :: new ienumerable 
Csharp :: c# create console for winform 
Csharp :: calculate how much memory an object take c# 
Csharp :: change column name in datatable C# 
Csharp :: or c# 
Csharp :: c# foreach object in array json 
Csharp :: difference between boxing and unboxing in java 
Csharp :: c# webclient post file 
Csharp :: unity text color 
Csharp :: c# empty array 
Csharp :: minimize maximize restore wpf buttons 
Csharp :: c# get battery level 
Csharp :: bundle.config in mvc is missing 
Csharp :: c# quit button script 
Csharp :: modulus program 
Csharp :: how to find the tag of an objecdt in unity 
Csharp :: unity reference textmeshpro 
Csharp :: check if palindrome recursion in c# 
Csharp :: c# int 
Csharp :: add spaces in string 
Csharp :: All Possible SubString of string 
Csharp :: set margin programmatically wpf c# 
Csharp :: primitive types c# 
Csharp :: parametrizedthreadstart C# 
Csharp :: nexo price 
Csharp :: set text in unity invisible 
Csharp :: c# get date without time 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =