Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity wheelcollider antiroll

//Make it impossible to flip the car:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Antiroll : MonoBehaviour
{

	public WheelCollider WheelRL;
	public WheelCollider WheelRR;
	public WheelCollider WheelFL;
	public WheelCollider WheelFR;
    
	public float AntiRoll = 500f;

	public Rigidbody car;

	void Update()
	{
		if (WheelRL.isGrounded)
			car.AddForceAtPosition(-WheelRL.transform.up * AntiRoll, WheelRL.transform.position);
		if (WheelRR.isGrounded)
			car.AddForceAtPosition(-WheelRR.transform.up * AntiRoll, WheelRR.transform.position);
		if (WheelFL.isGrounded)
			car.AddForceAtPosition(-WheelFL.transform.up * AntiRoll, WheelFL.transform.position);
		if (WheelFR.isGrounded)
			car.AddForceAtPosition(-WheelFR.transform.up * AntiRoll, WheelFR.transform.position);
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# check if there is 5 mins space between two datestime 
Csharp :: c# methods 
Csharp :: how to access a dictionary in c# 
Csharp :: aws asp.net tutorial 
Csharp :: publish applications for linux 
Csharp :: Delegates in UntiyC# 
Csharp :: how to detected WindowCloseEvent in other window wpf 
Csharp :: scale curve revit api 
Csharp :: how to close a popup wpf c# on click event 
Csharp :: pyqt single instance 
Csharp :: C# Printing Variables and Literals using WriteLine() and Write() 
Csharp :: orderby make sunday last day c# 
Csharp :: init stirng list c# 
Csharp :: conevrt list to pipe separated string c# 
Csharp :: c# array accessor 
Csharp :: c# copy each property 
Csharp :: regex ip rage detect c# 
Csharp :: c# decimal 
Csharp :: palindromes 
Csharp :: check list exist in list c# if matches any 
Csharp :: c# close all threads application exit 
Csharp :: unity3d sort list 
Csharp :: web scraping dynamic content c# 
Csharp :: stackpanel opacity mask from resources wpf 
Csharp :: project programing languages in codecademy 
Html :: href do nothing 
Html :: ion-content background color 
Html :: link css html 
Html :: link email anchor to open up users email address 
Html :: centre text bootstrap 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =