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 :: how to get total scenes unity 
Csharp :: unity get center of object 
Csharp :: how to get previous page url aspnet core 
Csharp :: c# merge two xml files 
Csharp :: IHttpContextAccessor 
Csharp :: c# get list item in random order 
Csharp :: join array in c# 
Csharp :: how to get row index of selected row in gridview asp.net webforms 
Csharp :: unity rotate around axis 
:: c# get serial ports 
Csharp :: how to add to a list only items that are not already in the list c# 
Csharp :: What is the yield keyword used for in C#? 
Csharp :: type or namespace text could not be found unity 
Csharp :: difference between awake and start unity 
Csharp :: authentication and authorization in asp.net c# with example 
Csharp :: variable size in memory c# 
Csharp :: c# nullable generic 
Csharp :: iterate though data in firebase unity 
Csharp :: Commenting on C# 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =