Quantcast
Channel: Questions in topic: "wheelcollider"
Viewing all 490 articles
Browse latest View live

Front wheel rotates in play mode

$
0
0
Hello! My front right wheel looks all right when I am in scene mode, but once I enter play mode it rotates 180 degrees and is facing inside. This is not happening to any other wheel. The problem goes away if I delete the Steering rotation portion of the code. **Can you spot the problem?** Thanks in advance! void Update () { // Steering rotation Vector3 wheelFLTransAngle = wheelFLTrans.localEulerAngles; Vector3 wheelFRTransAngle = wheelFRTrans.localEulerAngles; wheelFLTransAngle.y = wheelFL.steerAngle - wheelFLTrans.localEulerAngles.z; wheelFRTransAngle.y = wheelFR.steerAngle - wheelFRTrans.localEulerAngles.z; wheelFRTrans.localEulerAngles = wheelFRTransAngle; wheelFLTrans.localEulerAngles = wheelFLTransAngle; // Wheel rotation wheelFLTrans.Rotate (wheelFL.rpm / 60 * 360 * Time.deltaTime, 0, 0); wheelFRTrans.Rotate (wheelFR.rpm / 60 * 360 * Time.deltaTime, 0, 0); wheelBLTrans.Rotate (wheelBL.rpm / 60 * 360 * Time.deltaTime, 0, 0); wheelBRTrans.Rotate (wheelBR.rpm / 60 * 360 * Time.deltaTime, 0, 0); }

Wheel Collider steering problem

$
0
0
hi ..... im using wheel collider for car ...but when i steer the car flip this may script; var motorPower:float = 20; var steerPower:float = 20; var backWheel1:WheelCollider; var backWheel2:WheelCollider; var frontWheel1:WheelCollider; var frontWheel2:WheelCollider; var vs :float; var hs :float; function Start(){ motorPower = 300; steerPower = 50; } function Update(){ vs = Input.GetAxis("Vertical")* motorPower; hs=Input.GetAxis("Horizontal")*steerPower; backWheel1.motorTorque = vs; backWheel2.motorTorque = vs; frontWheel1.steerAngle = hs; frontWheel2.steerAngle = hs;

Wheels are going inside plane

$
0
0
Have a vehicle with Cube rigidbody, wheels and wheel colliders. ![alt text][1] However when my car turn over to side, the wheels are going inside plane. ![alt text][2] Any way to fix this? [1]: /storage/temp/18884-screen+shot+2013-12-04+at+22.21.12.png [2]: /storage/temp/18885-screen+shot+2013-12-04+at+22.24.48.png

why my car steering when apply motorTorque

$
0
0
I have a simple car model: a plane with box collider, 4 wheel and 4 wheelcollider. I have already check that wheelcollider are symmetric, balancet whith other component. when I apply motorTorque to 2 wheelCollider, car steering automatically, one time at right, other at left. I've no idea why.

Car moving in right direction.

$
0
0
I am a unity beginner and making a simple car game. I have set the wheel collider according to this tutorial car tutorial When i give torque the car is moving forward but also in right direction. Here is my code private void FixedUpdate () { FL_WheelMesh.Rotate(FL_WheelCollider.rpm/60f * 360f * Time.deltaTime, 0f, 0f); FR_WheelMesh.Rotate(FR_WheelCollider.rpm/60f * 360f * Time.deltaTime, 0f, 0f); RL_WheelMesh.Rotate(RL_WheelCollider.rpm/60f * 360f * Time.deltaTime, 0f, 0f); RR_WheelMesh.Rotate(RR_WheelCollider.rpm/60f * 360f * Time.deltaTime, 0f, 0f); FL_WheelCollider.motorTorque = currentTorque; FR_WheelCollider.motorTorque = currentTorque; CarMovement(); } private void CarMovement() { switch(carState) { case CarState.still : { currentTorque = 0; } break; case CarState.accelerate : { if(currentTorque < maxTorque) currentTorque += 10 * Time.deltaTime; else currentTorque = maxTorque; } break; case CarState.deaccelerate : { if(currentTorque > 0) currentTorque -= 5 * Time.deltaTime; } break; case CarState.brake : { if(currentTorque > 0) currentTorque -= 10 * Time.deltaTime; else currentTorque = 0; } break; default : break; } } void OnGUI() { if(GUI.RepeatButton(new Rect(600, 350, 100, 50), "UP")) { Debug.Log("---- ACCELERATE ----- "); carState = CarState.accelerate; } if(GUI.RepeatButton(new Rect(600, 450, 100, 50), "DOWN")) { Debug.Log("---- BRAKE ----- "); carState = CarState.brake; } }

Custom Wheel Collider Suspension

$
0
0
I am trying to make a Custom WheelCollider but i have a few problems.float SuspensionForce = SuspensionSpring * (m_suspensionCompression + m_suspensionCompressionPrev) / 2 + SuspensionDamper * (m_suspensionCompression - m_suspensionCompressionPrev) / Time.fixedDeltaTime; 1. Damper cause vibration, High damping = High Vibration 2. System never getting stable 3. Is there a way to limit max compression? 4. Is there a way to sleep rigidbody when its stable? As i know, applying force will wake it up. Help! What should i do for a realistic Wheel? m_suspensionCompression unit: meters
SpringForce = SpringCoefficient * compressiondistance;

DampingForce = DampingCoefficient * compressionspeed;
Currently compression calculating form raycast hitpoint.

Anyway to know amount of spring compressed?

$
0
0
Well I'm trying to get the information on how much the spring is compressed. Lets say that it have a spring value of 400, how do I know how much force its receiving? Or how much its compressed? Or how much distance it have to travel?

car not moving straight

$
0
0
I am trying to make a simple car game but whenever i am pressing up arrow the car is moving to right. This is the code i am using and attached to the car gameobject public WheelCollider wheelFL, wheelFR, wheelRL, wheelRR; public float maxTorque = 50f; public float steerFactor = 10f; void Start () { rigidbody.mass = 1500f; rigidbody.centerOfMass = new Vector3(0f, -0.9f, 0f); } void FixedUpdate () { wheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical"); wheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical"); wheelFL.steerAngle = steerFactor * Input.GetAxis("Horizontal"); wheelFR.steerAngle = steerFactor * Input.GetAxis("Horizontal"); } Here is how wheel colliders are set ![wheels][1] [1]: /storage/temp/21278-wheels.jpg

WheelCollider: veering/drifting bug?

$
0
0
I know there have been a bunch of questions related to this but I've not yet found a satisfactory answer. Apologies if you're sick of hearing about this! I've created a super simple 'car'. With four gameobjects with wheelcolliders positioned precisely symmetrically around the body (which has a rigid body attached). The car is placed on a simple plane. If i make the car 'go' by adding motortorque to the back wheels, the car will veer to one side quite dramatically as it travels. Is this somehow expected behaviour or a bug? If it's expected, why is it happening? ![alt text][1] [1]: http://i.imgur.com/vA8gDOv.gif

Add Force or Motor Torque .. Which is better for creating a car?

$
0
0
Hi guys, I was looking into the unity car tutorial available in the unity asset store. In the tutorial force was applied to the rigid body of car to make it move and also to simulate drag. There is also a tutorial in youtube in which motor torque is applied to wheel collider to make the car move. So my question is which is a better approach to make a car? Assest Store Tutorial : http://u3d.as/content/unity-technologies/car-tutorial/1qU Youtube Tutorial : www.youtube.com/watch?v=c5Snsi68xzE Thanx in advance!

WheelCollider climbing the wall

$
0
0
Hello! Sorry for broken language :) I'm trying to make arcade car model and experiencing an issue with its wheels. Simple car model with normally oriented wheelcolliders. Simple track surrounded with borders. I want my car on colliding with wall just slide along it (if angle of impact is appropriate), but car climbs on it. I'm happy with car movements and physics on flat space but when car model colliding with wall - it climbs up. I'm not talking about head-on impact on huge speed. Even on low speed if drive along a wall and collide with it. ![alt text][1] I've tried to play with physic materials of wall and car colliders (Friction). Even friction=0 on both solids. No luck. I've tried to make car collider wider wheels base - unacceptable due to weird behaviour while jumps/collides and anyway it collides at strange poses. On attached image you can see boundaries and center of mass. ![alt text][2] I tried all of obvious things but suppose that I missing something. Thanks for any advice! [1]: /storage/temp/25200-2014-04-15+05_28_13-.png [2]: /storage/temp/25201-vehicle_view.png

Wheel picker

$
0
0
I need to create a wheel picker to my car configurator. please anybody help me to create it I need to create a wheel palette and script too. if anyone having please post the steps and wheel picker tool (not from the asset store)

Do wheel colliders account for wheel width?

$
0
0
hello, i am still fairly new to unity and want to make a sandbox game, that will have vehicles involved and i was wondering if there was any way to make my actual wheels act as wheel colliders, or if the unity wheel colliders could take into account customized wheel widths, because i noticed that the unity wheel collider is represented by a paper thin circle. and i am not sure if that is the reason why the last time i tried to make a car in unity it kept rolling over, i know that with wider wheels it adds more stability, and you can also send more torque through the wheels with less loss of traction.

How to get wheel spin with a Wheel Collider

$
0
0
Hi all, I am attempting to make a basic car game and have set my vehicle up with a few colliders. When I pull the vehicle up to a wall in an attempt to spin the wheels I get 5rpm. I car can fly along, but can't spin at all with reasonable numbers. I can get wheel spin/a higher rpm, but only with front friction of 0.0005 and torque of 150,000 which seems crazy. All my wheels are 1x1x1 scale, and the vehicle only weighs 1500. They weigh 25 each and have a rad of 1. My acceleration code is: `RLWheelCollider.motorTorque = torque * Input.GetAxis ("Vertical");` for both rear wheels. Why are these values at such extremes? Edy's vehicles get wheelspin with standard friction curves scaled down to 0.2. Also a sidenote - the vehicle can still flip with a sideways factor of 0.001..? So if the same issue is causing that I'd be even more thankful for a solution. Cheers

Add colliders without affecting rigidbody behaviour?

$
0
0
Is it possible to add colliders without affecting the behaviour of the rigidbody? Me and my friend are making a car game and when we don't add our vehicle colliders, it drives around and skids perfectly! The moment we add our colliders it flips instantly, is there a way to add the colliders and make them for collision only? It's been annoying me for hours.

Brake Torque on Wheel Collider not working

$
0
0
Brake Torque not working on my wheel collider Here's the script using UnityEngine; using System.Collections; using System.Collections.Generic; class tappersecondtest : MonoBehaviour { //car gameobject stuff public WheelCollider FrontWheel; public WheelCollider BackWheel; //car stats stuff public float accrate; public float decrate; public float fuel; //bools car stuff public bool movingforward; public bool reversing; public bool dead; public bool CarGrounded; //extra car stuff float waitingtimeforreverse = 2; public bool waitedforreverse; //public GUI taps per second stuff public GUIText guicurrenttouchstat; public GUIText guitappersec; public GUIText movingforwardcheck; public GUIText movingbackwardcheck; public GUIText accratecheck; public GUIText decratecheck; public GUIText fuelcheck; public GUIText waitingreversetimecheck; public GUIText waitingtimechecktrue; public GUIText braketorquecheck; //Touchscreen car movement stuff private List taps = new List (); public float tapsPerSecond; void Start () { Vector3 center = rigidbody.centerOfMass; rigidbody.centerOfMass = center; } void FixedUpdate() { if(dead != true) { if(movingforward == true) { FrontWheel.brakeTorque = 0; BackWheel.brakeTorque = 0; FrontWheel.motorTorque = 1 * accrate * tapsPerSecond; BackWheel.motorTorque = 1 * accrate * tapsPerSecond; } if(reversing == true) { if(waitedforreverse = false) { FrontWheel.brakeTorque = 1000; BackWheel.brakeTorque = 1000; } waitingtimeforreverse -= Time.deltaTime; if (waitingtimeforreverse <= 0) { waitedforreverse = true; FrontWheel.brakeTorque = 0; BackWheel.brakeTorque = 0; FrontWheel.motorTorque = -1 * decrate * 2; BackWheel.motorTorque = -1 * decrate * 2; } } else { waitedforreverse = false; waitingtimeforreverse = 2; } if(CarGrounded == false) { if(Input.touchCount == 1) { int i = 0; for(i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if(touch.position.x < Screen.width/2) { transform.Rotate (-Vector3.forward, 30 * Time.deltaTime); } if(touch.position.x > Screen.width/2) { transform.Rotate (Vector3.forward, 30 * Time.deltaTime); } } } } } } void Update () { //guitext stuff guitappersec.text = tapsPerSecond.ToString(); fuelcheck.text = fuel.ToString(); accratecheck.text = accrate.ToString(); decratecheck.text = decrate.ToString(); braketorquecheck.text = "(" + FrontWheel.brakeTorque + ")" + "" + "(" + BackWheel.brakeTorque + ")"; waitingreversetimecheck.text = waitingtimeforreverse.ToString (); if(movingforward != true && reversing != true) { guicurrenttouchstat.text = "not touching screen"; } else { guicurrenttouchstat.text = "touching screen"; } if(movingforward == true ) { movingforwardcheck.text = "moving forward"; } else { movingforwardcheck.text = "not moving forward"; } if(reversing == true) { movingbackwardcheck.text = "reversing"; } else { movingbackwardcheck.text = "not reversing"; } if(waitedforreverse == false) { waitingtimechecktrue.text = "waiting for reversing"; } else { waitingtimechecktrue.text = "waited is reversing"; } //end guitext stuff //taps per second if(CarGrounded == true) { foreach (Touch touch in Input.touches) { if(Input.touchCount == 1) { if (touch.phase == TouchPhase.Ended) { if(touch.position.x > Screen.width /2) { taps.Add(Time.timeSinceLevelLoad); } } } } } for (int i = 0; i < taps.Count; i++) { if (taps[i] <= Time.timeSinceLevelLoad-1) { taps.RemoveAt(i); } } tapsPerSecond = taps.Count; //end taps per second //reverse if(CarGrounded == true) { if(Input.touchCount == 1) { int i = 0; for(i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if(touch.position.x < Screen.width/2) { if(touch.phase != TouchPhase.Ended) { reversing = true; } else reversing = false; } } } else { reversing = false; } } //end reverse //moving is true if tap is more than ONE if(tapsPerSecond > 0) { movingforward = true; } else { movingforward = false; } // end moving is true //fuel decrease if ((movingforward)) is true if(movingforward == true || reversing == true) { fuel -= Time.deltaTime; } //end fuel decrease if is true //car stats stuff in Update if (movingforward == true) { accrate += Time.deltaTime; } else { accrate = 0; } if (reversing == true) { decrate += Time.deltaTime; } else { decrate = 0; } //locks if(accrate >= 7) { accrate = 7; } if(decrate >= 12) { decrate = 12; } //end locks //end car stats stuff in Update //Car Grounded Locks if(FrontWheel.isGrounded == true && BackWheel.isGrounded == true) { CarGrounded = true; } else { CarGrounded = false; } if(CarGrounded == false) { //car bools movingforward = false; reversing = false; } } } I use the GUI.text to measure the brake torque on each wheel but all returns 0 even when my waited for reverse is false.Any ideas? thanks

wheelcollider brakeTorque acts irrational

$
0
0
Hello, I'm experimenting with wheel colliders and having quite a few issues, especially with the braketorque. I have set my vehicle up initially so that 40% of the torque goes to the front wheels and 60% to the rear wheels to mimic that of most all wheel drive cars nowadays. however, my problem is that when i apply the brake force while i am stationary to mimic a handbreak (i.e. so only the rear tires receiving a very large brake force in the range of 10000), if i turn the steering wheel, the car starts spinning in reverse, with the rear tires glued in place, however the front end of the vehicle is still spinning. Changing the sideways friction of the wheels only changes the speed it rotates at. I have tried this both with continuing to apply torque from the engine to the rear wheels when the handbrake is activated, and by stopping the torque from the rear tires when the brakes are activated. in anycase it still continues to spin in reverse at different speeds. Would anyone know how the braketorque works exactly and what could be the cause of this? as i find it strange that the rear wheels are somehow affecting the front wheels, without them moving themselves, so i assume that all wheels attached to a rigidbody must showhow be connected? EDIT: Sorry just to add to that, if i change the rear tire stiffness for both sideways and forwards to 0, when pressing the handbrake and accellerating, rather than being pulled from the front tires the car still simply spins in place, except this time it spins around the front axel rather than the rear.

Wheel Collider Behaving a bit Strange in unity 5. Any ideas?

$
0
0
Hello! I just got unity5 and i straight off went to make a vehicle to test the new physics engine. When i went to start coding the car. I hit Play and the car landed. and it Just went like freakin free-style all over the place... Any Ideas is to what could of went wrong? here's my code: public WheelCollider pivotFL; public WheelCollider pivotFR; public WheelCollider pivotRL; public WheelCollider pivotRR; public Transform meshFL; public Transform meshFR; public Transform meshRL; public Transform meshRR; Rigidbody car; void Start() { car = GetComponent(); } This is All i did... Any help is sooo welcome :D Thanks again!

Error CS0120 and CS1612 - Wheelcollider sidewaysFriction and Rigidbody.velocity

$
0
0
**I'm currently working on a car project due in 2 days, and having some issues:** The error I'm having is: *"CS1612(XX,25(XX represents line 59-62)): Cannot modify a type return value of 'UnityEngine.WheelCollider.sidewaysFriction'. Consider storing the value in a temporary variable"* Here's my (C#)Code (I Used the '*' to show the error area): using UnityEngine; using System.Collections; public class DriveScriptC : MonoBehaviour{ public float motorForce; public float SteerAngle; public WheelCollider BLWheel; public WheelCollider BRWheel; public WheelCollider FLWheel; public WheelCollider FRWheel; public float brakeForce; public GameObject fin; public bool CheckpointA; public float slip;//slip of the velicle public float hit; public WheelFrictionCurve sidewaysFriction; // Use this for initialization void Start () {//what vars are slip = 0; CheckpointA = false; fin = GameObject.FindWithTag ("Finish"); } // Update is called once per frame void Update () { float v = Input.GetAxis ("Vertical") * motorForce;// float h = Input.GetAxis ("Horizontal") * SteerAngle;//declaring var //motor power BLWheel.motorTorque = v; BRWheel.motorTorque = v; //steering FLWheel.steerAngle = h; FRWheel.steerAngle = h; if (Input.GetKey (KeyCode.Space)) {//When SpaceBar is down(held), apply brake BLWheel.brakeTorque = brakeForce; BRWheel.brakeTorque = brakeForce; } if (Input.GetKeyUp (KeyCode.Space)){//When SpaceBar is up(not held), don't apply brake BLWheel.brakeTorque = 0; BRWheel.brakeTorque = 0; } *slip = 0.001 + 0.022 / (rigidbody.velocity.magnitude + 1);* *//velocity-slip curve* *FLWheel.sidewaysFriction.stiffness = slip*Time.deltaTime; // X* *FRWheel.sidewaysFriction.stiffness = slip*Time.deltaTime; // XX* *BLWheel.sidewaysFriction.stiffness = slip*Time.deltaTime; // XXX* *BRWheel.sidewaysFriction.stiffness = slip*Time.deltaTime; //XXXX* WheelHit FLhit; WheelHit FRhit; WheelHit BLhit; WheelHit BRhit; if(FLWheel.GetGroundHit(out FLhit)){ if(FLhit.collider.gameObject.tag == "Finish"){ if(CheckpointA == true){//if Checkpoint selected print("FINISH!");//Print "Finish" } } } if(FRWheel.GetGroundHit(out FRhit)){ if(FRhit.collider.gameObject.tag == "Finish"){ if(CheckpointA == true){//if Checkpoint selected print("FINISH!");//Print "Finish" } } } if(BLWheel.GetGroundHit(out BLhit)){ if(BLhit.collider.gameObject.tag == "Finish"){ if(CheckpointA == true){//if Checkpoint selected print("FINISH!");//Print "Finish" } } } if(BRWheel.GetGroundHit(out BRhit)){ if(BRhit.collider.gameObject.tag == "Finish"){ if(CheckpointA == true){//if Checkpoint selected print("FINISH!");//Print "Finish" } } } } } I *do* admit, I *am* kind of a newbie...

Wheel has no friction on mesh collider of another GameObject.

$
0
0
Good day! I'm working on a mod for the Kerbal Space Program, a game that is based on **Unity 4.5.5** And I have a problem with (I think) WheelColliders: In a scene I have **a terrain** and **a garage** *(GameObject with a RigidBody and several mesh colliders which are its floor, walls and ceiling)*. The garage stands still on that terrain. I also have **a simple car with four wheels** that use WheelColliders. While the car drives on the terrain wheels work as expected and changing of FrictionCurves' parameters modifies their behaviour accordingly. But when the car rides inside the garage on top of the floor WheelCollider *(which is as thick as ~1/4 of the wheel's diameter)* wheels start to slip and have no grip at all, no friction. And changing their FrictionCurves have no effect. Googling gives nothing on the problem, so I write here. Do you have any clue as to where the problem may be, or at least some advices on debugging it? I've spend many days on it and completely out of ideas.
Viewing all 490 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>