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

how to decrease velocity of a Unity rigidbody

//Drecrese Rigidbody Speed
[SerializeField] private Rigidbody rb;

void FixedUpdate() {
  //Decrease speed
  rb.velocity -= rb.velocity * 0.1f;
}
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 :: unity get perlin noise 3d 
Csharp :: see if two string arrays are equal c# 
Csharp :: process.start web 
Csharp :: c# create dynamic json 
Csharp :: flip a character in unity 
Csharp :: unity new vector3 
Csharp :: how to import datagridview to datatable in c# 
Csharp :: unity call function on animation onstateexit 
Csharp :: difference between alpha and beta testing 
Csharp :: c# if int is in range 
Csharp :: how to add a gameobject 
Csharp :: how to get the transform of an object in unity 
Csharp :: html.beginform 
Csharp :: Pass Querystring in C# httpclient 
Csharp :: how to get specific length of row in matrix c# 
Csharp :: check if file exist c# 
Csharp :: get current time c# 
Csharp :: unity deactivate component 
Csharp :: get file extension in c# file upload 
Csharp :: c# remove word from string 
Csharp :: HCF of list of number 
Csharp :: difference between boxing and unboxing in java 
Csharp :: list to array c# 
Csharp :: .net core web app get dll name 
Csharp :: set target framerate unity 
Csharp :: convert decimal to 2 decimal places c# 
Csharp :: linq query get last day of month 
Csharp :: c# wpf image source from resource programmatically 
Csharp :: unity gui style color button 
Csharp :: default parameter c# 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =