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

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.

Problem with WheelCollider (with image)

$
0
0
When I put a WheelCollider to wheel, it's not placing same orientation with wheel, how to fix this issue? Is it related to model? Edit : It was related to model, designer fixed it. ![s][1] [1]: http://i.gyazo.com/951a30a82ea3f23e4a30e2b41118cd90.png

With wheel collider my car not landing properly in slops, it gives jumping effect when not all four wheels are grounded?

$
0
0
I am using wheel collider for bring up a monster car physics, i got succeeded with the physics but the problem is its stats jumping in the slops its looks pretty odd. i do made changes to suspension but i am not getting what i am looking for, The car gives a bad jumping effect when it is landing with two wheels on ground and other two are about to ground its starts jumping ugly. any help would be appreciated. Thank you

Wheelcollider Speeding Up on a slope!

$
0
0
Hello everyone. I need some help. I have followed 'FlatTutorials' videos on how to make a car game. Here is the code: // If speed limiter is on, disable speed when we hit top speed. if (currentSpeed >= topSpeed && speedLimited == true && !handbrake){ wheelRR.motorTorque = 0; wheelRL.motorTorque = 0; } else if(!handbrake) { // This is where the power is applied to the wheels wheelRR.motorTorque = engineTorque * Mathf.Clamp(Input.GetAxis("Vertical"),-1,1); wheelRL.motorTorque = engineTorque * Mathf.Clamp(Input.GetAxis("Vertical"),-1,1); if (!Input.GetAxis("Vertical")){ wheelRR.brakeTorque = 30; wheelRL.brakeTorque = 30; } else { wheelRR.brakeTorque = 0; wheelRL.brakeTorque = 0; wheelRR.brakeTorque = brakeTorque * -1 * Mathf.Clamp(Input.GetAxis("Vertical"),-1,0); wheelRL.brakeTorque = brakeTorque * -1 * Mathf.Clamp(Input.GetAxis("Vertical"),-1,0); } } I have a problem though - when I go up slopes, my car speeds up a lot and it's very unrealistic. If anyone has a solution I would be very grateful.

Wheelcolliders falling through ground

$
0
0
Hello, I need some help with wheel colliders. I have made a car model in blender and imported it to unity. There I have attached four wheel colliders, one for each wheel, everyone in a single empty game object parented to the main car object. I have aligned them so the sit around the edge of the wheels. I have a terrain also made in blender that the car rides on that has a mesh collider. If I only drive along the surface the wheel colliders work but if the car is dropped from some height or is trying to turn to rapidly, some or all wheels go through the mesh collider. It seems to be a problem not only with meshcolliders since I have a unity terrain object also in my scene and it acts the same way there. I've tried to work around the problem using a second collider in a sibling object to every wheel collider, of type spherecollider that uses a frictionless physics material however these colliders dont react nicely with the kinks in the meshcollider suddenly just stopping and such. The only suggestion that I can come up with regarding whats happening is that the verts in the mesh collider is spread out, my ground mesh is quite low poly, so that the wheel collider has trouble finding it. If anyone has any thoughts I'd appreciate it!

Wheel Colliders stop working when hitting sharp angles.

$
0
0
What would cause wheel colliders in general to stop working when either getting stuck or hitting sharp angles? My vehicle can hit walls and still continue driving but if I try to hit or drive up a slope my wheel colliders stop working entirely. Its' almost as if it has no traction or the wheel isn't touching. I was thinking that maybe my rigidbody falls asleep but i have two ways of keeping it "awake" within my code. using UnityEngine; using System.Collections; public class broncotest : MonoBehaviour { public Rigidbody vehicle; // public WheelCollider flc; public WheelCollider frc; public WheelCollider lrc; public WheelCollider rrc; // public Transform tfl; public Transform tfr; public Transform tlr; public Transform trr; public Transform com; // public Vector3 vfl; public Vector3 vfr; public Vector3 vlr; public Vector3 vrr; public Vector3 vcom;//vector3 for center of mass object // public WheelFrictionCurve fc_flc; public WheelFrictionCurve fc_frc; public WheelFrictionCurve fc_lrc; public WheelFrictionCurve fc_rrc; // public float flsfric;//front left side friction curve // public float frsfric;//front right side friction curve // public float lrsfric;//left rear side friction curve // public float rrsfric;//right rear side friction curve // public bool overturned;//yes no check if player is upside down. public bool preverse;//yes no check if player is in reverse. public bool stalled;//yes no check if player has stalled. based on either damaged or weapon hit with. public bool destroyed;//yes no check if player has been destroyed. public bool isEmergencyBraking; public bool isFlGrounded;//is front left tire grounded? public bool isFrGrounded;//is front right tire grounded? public bool isLrGrounded;//is left rear tire grounded? public bool isRrGrounded;//is right rear tire grounded? public bool isMph; public bool isKph; // public float comlz = 0f; public float comly = 0.35f; public float comlx = -.96f; public float comrz = 0f; public float comry = 0.35f; public float comrx = .96f; public float comnz = 0f; public float comny = 0f; public float comnx = 0f; // public float totalcondition;//the total average health for the player public float conflc;//condition of front left tire public float confrc;//condition of front right tire public float conlrc;//condition of left rear tire public float conrrc;//condition of right rear tire public float conmotor;//condition of motor // public float forward;//general movement. Doesn't count speed. 1 = forward / -1 = reverse. public double mph;//MPH speed check. public double kph;//KPH speed check. public float mphconvert;//dbl to float public float kphconvert;//dbl to float public float minmph = 0;//MPH speed min check. public float minkph = 0;//KPH speed min check. public float maxmph = 120;//MPH speed max check. public float maxkph = 193;//KPH speed max check. public float clampmph;//clamp base for mph public float clampkph;//clamp base for kph //public float reverse; public float mboost = 30f; public float fspeed = 30f; //should always be the same speed as driving forward. public float rspeed = 15f; //reverse speed. shouldn't be too fast. public float lrrpm; public float rrrpm; //public float rboost = 15f; //private float mmin = -15f; //private float mmax = 30f; // public float steering; private float sboost = 20f; //private float smin = -20f; //private float smax = 20f; // public float braking; private float bboost = 50f; //private float bmin = 0f; //private float bmax = 10f; // public float lrtorque; public float rrtorque; public float lsteering; public float rsteering; public float lbraking; public float rbraking; // Use this for initialization void Start () { //isMph = true; //isKph = false; vehicle.WakeUp ();//wake up pls } void Update () { } // Update is called once per frame void FixedUpdate () { // mph = vehicle.velocity.sqrMagnitude * 2.237;//MPH // kph = vehicle.velocity.sqrMagnitude * 3.6;//kph // mphconvert = (float)mph; // kphconvert = (float)kph; // clampmph = Vector3.ClampMagnitude (mphconvert, minmph, maxmph);//clamp for min / max MPH // clampkph = Mathf.Clamp (kphconvert, minkph, maxkph);//clamp for min / max KPH vehicle.centerOfMass = com.localPosition; //vehbalancer (); healthmanager ();//PLAYER HEALTH MANAGER. EACH INDIVIDUAL PLAYER / AI NEEDS THIS inputmanager ();//MANAGES PLAYER INPUT wheelgrounded ();//mostly for debugging i guess. checks all wheels if they are touching ground. vehiclestabilizer (); if (vehicle.IsSleeping ()) { vehicle.WakeUp ();//pls } } void inputmanager () { fc_flc = flc.sidewaysFriction; fc_frc = frc.sidewaysFriction; fc_lrc = lrc.sidewaysFriction; fc_rrc = rrc.sidewaysFriction; vfl = tfl.localEulerAngles; vfr = tfr.localEulerAngles; vlr = tlr.localEulerAngles; vrr = trr.localEulerAngles; // forward = Mathf.Clamp (Input.GetAxis ("Vertical"), -1, 1); steering = Mathf.Clamp (Input.GetAxis ("Horizontal"), -1, 1); braking = Mathf.Clamp (Input.GetAxis ("Braking"), 0, 1); //find if upside down with collider.isGrounded(); // lrc.motorTorque = forward * mboost; rrc.motorTorque = forward * mboost; //frc.motorTorque = forward * mboost; //flc.motorTorque = forward * mboost; // lrc.brakeTorque = braking * bboost; rrc.brakeTorque = braking * bboost; // flc.steerAngle = steering * sboost; frc.steerAngle = steering * sboost; vfl.y = steering * sboost; vfr.y = steering * sboost; //_____________________________________________________// // lrrpm = Mathf.Clamp (lrc.rpm, 0, 100); rrrpm = Mathf.Clamp (rrc.rpm, 0, 100); lrtorque = lrc.motorTorque; rrtorque = rrc.motorTorque; vlr.x = lrrpm; vrr.x = rrrpm; vfl.x = lrrpm; vfr.x = rrrpm; tlr.localEulerAngles = vlr; trr.localEulerAngles = vrr; tfl.localEulerAngles = vfl; tfr.localEulerAngles = vfr; // lsteering = flc.steerAngle; rsteering = frc.steerAngle; // lbraking = lrc.brakeTorque; rbraking = rrc.brakeTorque; // if (Input.GetButtonDown ("Braking")) { isEmergencyBraking = true; if (lrc.isGrounded) { fc_lrc.stiffness = 0.1f; fc_rrc.stiffness = 0.1f; } } else if (Input.GetButtonUp ("Braking")) { isEmergencyBraking = false; if (rrc.isGrounded) { fc_lrc.stiffness = 1f; fc_rrc.stiffness = 1f; } } if (forward > 0) { //Means player is trying to go forward mboost = fspeed;//sets to forward speed. Each vehicle will have a different speed. } else if (forward < 0) {//Means player is trying to reverse mboost = rspeed;//set reverse speed to lower number than forward. Seems realistic. Each vehicle will have a different speed. } GameObject[] wcobj = GameObject.FindGameObjectsWithTag ("wheelcollider"); foreach (GameObject wc in wcobj) { if (wc.transform.root.tag == "Player") { //OK COOL ITS' THE PLAYER. WHAT NOW? } else { //NOPE NOT THE PLAYER. MUST BE AI } if (wc.GetComponent ().isGrounded == false) { if (wc.transform.root.eulerAngles.y >= 90 && wc.transform.root.eulerAngles.y <= 270) { //90 \ 270. BETWEEN THESE TWO MEANS ON SIDES OR UPSIDE DOWN //ROLL OVER VEHICLE THAT THESE WHEEL COLLIDERS BELONG TO. NEED TO PREVENT ALL PLAYERS / AI FROM BEING FLIPPED. } else { //MUST HAVE AT LEAST ONE TOUCHING THE GROUND. } } } } void vehbalancer () {//THE CENTER OF MASS SYSTEM. //----------------|-----------------// //----------------|-----------------// //----------------|-----------------// //------------/////////-------------// //------------//-----//-------------// //--------____//--+--//____---------// //------------//-----//-------------// //------------/////////-------------// //----------------|-----------------// //----------------|-----------------// //----------------|-----------------// //THE IDEA IS TO HAVE THE CENTER OF MASS MOVE WITH VEHICLE INSTEAD OF USING "STABILIZER BARS". //TURNING LEFT CAUSES THE CENTER OF MASS TO MOVE TO THE LEFT JUST ENOUGH TO BALANCE THE CAR WITHOUT TOPPLING OVER //TURNING RIGHT CAUSES THE CENTER OF MASS TO MOVE TO THE LEFT JUST ENOUGH TO BALANCE THE CAR WITHOUT TOPPLING OVER //NEED TO FIGURE OUT A WAY TO CHECK IF VECHILE IS UPSIDE DOWN. vcom = com.localPosition; if (steering < 0) {//must be going left? Vector3 comleft = new Vector3 (comlx, comly, comlz); vcom = comleft; } else if (steering > 0) {//must be going right? Vector3 comright = new Vector3 (comrx, comry, comrz); vcom = comright; } else if (steering == 0) { Vector3 comneutral = new Vector3 (comnx, comny, comnz); vcom = comneutral; } com.localPosition = vcom; } void vehiclestabilizer () { } void wheelgrounded () {//FOR DEBUGGING USE. if (flc.isGrounded) { isFlGrounded = true; } else { isFlGrounded = false; } if (frc.isGrounded) { isFrGrounded = true; } else { isFrGrounded = false; } if (lrc.isGrounded) { isLrGrounded = true; } else { isLrGrounded = false; } if (rrc.isGrounded) { isRrGrounded = true; } else { isRrGrounded = false; } } void healthmanager () {//manages the player health. } } Video showing problem: https://www.youtube.com/watch?v=WuzGaYHPld4

Simpler Wheels (wheelCollider)

$
0
0
I'm making a game with potentially hundreds of cars on screen at one time... and I believe unity's build-in wheel colliders do suspension calculations that are unnecessary to my game. Is there a simpler(more efficient) method of making an object "slide and steer" along the terrain to simulate driving? I tried putting a "slippery" physics material on cubes and limit the friction direction and it kinda worked but was quite sketchy and didn't seem right, maybe there's a specific way of using "limited friction" that I don't know about?

Small objects colliding problem ("sink" in terrain).

$
0
0
I'm making simulation for my three wheeled robot, and i need to keep original size. My robot have diameter 15 cm and mass around 0.2. When i hit "play", i've got this effect: ![alt text][1] [1]: /storage/temp/33436-robot.png My object is not falling through terrain, but it sinks a few cm, and because that, the wheel colliders are not working properly. I know i could rescale the whole world, but i rather would like to avoid that. Is any way to edit terrain or some option in Unity, to make colliding more precise?

how to have a correct collision on wheel collider

$
0
0
I was hoping that unity 5 could resolve it but looking at their video it seems not: ![wheel collider collision][1] as you can see the wheel is intersecting the blue mesh because the wheel collider only raycasts down from the center of the wheel. This is not only a visual problem, but also creates a wrong physics result because the wheel is not pulling up the car at all. The car goes up only because is already moving forward with enough speed. But if you start from zero the car could just get sucked there. How do you suggest to resolve it? Any trick? Or I have to complete recode the behaviour of the wheel collider with some capsule collider, joints, etc.? [1]: /storage/temp/34377-screenshot+2014-10-27+14.41.49.jpg

OnCollisionEnter problem with wheel

$
0
0
Hi all, i have a big trouble with my cars wheel collider. my car calculating impacts and gives penalty to player. Problem is my impact script working with oncollisionenter and all my child colliders efects from it. when i try to drive my car and when road plane changes it startig calculate. cant i choos spesific child collider for my rigidbody calculations?

Wheel position is messed up

$
0
0
I've tried using this code: http://forum.unity3d.com/threads/advance-car-game-tutorials-unity-3d.158179/#post-1083357 on my "vehicle", but my wheels are kinda pointing up instead of down... :( ![alt text][1] [1]: http://i59.tinypic.com/avr6yv.png My entire code look like this: #pragma strict var WheelBR : WheelCollider; var WheelBL : WheelCollider; var WheelFR : WheelCollider; var WheelFL : WheelCollider; var wheelFLTrans : Transform; var wheelFRTrans : Transform; var wheelRLTrans : Transform; var wheelRRTrans : Transform; var Breaking = 20; function Update () { WheelPosition(); //This Code Puts Brakes On The Car. if (Input.GetKey(KeyCode.DownArrow)) { WheelBR.brakeTorque = Breaking; WheelBL.brakeTorque = Breaking; } //Keeps it rolling, when not braking { if (Input.GetKeyUp(KeyCode.DownArrow)) WheelBR.brakeTorque = 0; WheelBL.brakeTorque = 0; } //Wheel rotation visual { wheelRLTrans.Rotate(WheelBL.rpm/60*-360*Time.deltaTime,0,0); wheelRRTrans.Rotate(WheelBR.rpm/60*-360*Time.deltaTime,0,0); wheelFLTrans.Rotate(WheelFL.rpm/60*-360*Time.deltaTime,0,0); wheelFRTrans.Rotate(WheelFR.rpm/60*-360*Time.deltaTime,0,0); } } function WheelPosition(){ var hit : RaycastHit; var wheelPos : Vector3; //FL if (Physics.Raycast(WheelFL.transform.position, -WheelFL.transform.up,hit,WheelFL.radius-WheelFL.suspensionDistance) ){ wheelPos = hit.point+WheelFL.transform.up * WheelFL.radius; } else { wheelPos = WheelFL.transform.position -WheelFL.transform.up* WheelFL.suspensionDistance; } wheelFLTrans.position = wheelPos; //FR if (Physics.Raycast(WheelFR.transform.position, -WheelFR.transform.up,hit,WheelFR.radius-WheelFR.suspensionDistance) ){ wheelPos = hit.point+WheelFR.transform.up * WheelFR.radius; } else { wheelPos = WheelFR.transform.position -WheelFR.transform.up* WheelFR.suspensionDistance; } wheelFRTrans.position = wheelPos; //BL if (Physics.Raycast(WheelBL.transform.position, -WheelBL.transform.up,hit,WheelBL.radius+WheelBL.suspensionDistance) ){ wheelPos = hit.point+WheelBL.transform.up * WheelBL.radius; } else { wheelPos = WheelBL.transform.position -WheelBL.transform.up* WheelBL.suspensionDistance; } wheelRLTrans.position = wheelPos; //BR if (Physics.Raycast(WheelBR.transform.position, -WheelBR.transform.up,hit,WheelBR.radius+WheelBR.suspensionDistance) ){ wheelPos = hit.point+WheelBR.transform.up * WheelBR.radius; } else { wheelPos = WheelBR.transform.position -WheelBR.transform.up* WheelBR.suspensionDistance; } wheelRRTrans.position = wheelPos; } Any idea where i messed up? :D Thanks

how do i change the wheel collider stiffness with a script?

$
0
0
In my game, you can upgrade the tires. the real difference between tires is the stiffness on the wheel collider. I want the stiffness of the wheel to be changed by a script, but when I use the WheelCollider.forwardfriction.stifness , I get an error. I think you can also use WheelFrictioCurve. ive tried, but cant see the difference. how do i change the wheel collider stiffness with a script?

Instantiating a car prefab and adding wheel colliders to it

$
0
0
I am creating a car sumulation that has cars drive down a road toward a player. At the moment I have a car model prefab that I drag and drop into the scene. There is a script attached to that model that has a path and wheel collider variables, in the inspector I can drag and drop these path and collider variables onto the prefab. doing this everything works fine and the car drives down the road following the path. What I want to do now is instanciate the prefab and attach the path and wheel collider variables to the car prefab within another "GameMaster" script, I have some code but am a bit lost, the car gets instanciated but hasn't got a path or wheel colliders attached so it doesn't move. I am a noob and would really appericate any help. var craClone : GameObject; var path : GameObject; carClone = Instantiate(car); path = GameObject.Find("Path"); Debug.Log(path); carClone.path = path; //WheelFR = GameObject.Find("/car(Clone)/RivalCar/WheelColliders/WheelFR");

wheelcollider suspension car flies away

$
0
0
hello I have wheel colliders on my wheel with this code [code=CSharp] if(WheelFL.GetGroundHit(out hitA)) { WheelFLTrans.position = new Vector3(WheelFL.transform.position.x, hitA.point.y + 1.5f, WheelFL.transform.position.z); }[/code] wheer the wheeFL is the wheelcollider and the WheelFLTrans is the art for that wheel. but when i use this and drive over something it sometimes works but most of the time my car just flies away when it hits an object where it normally shoot use the suspension. these are my settings for the suspension. the mass of the car is 1500 ![alt text][1] hope someone can help me [1]: http://i59.tinypic.com/tagfw1.png

Making mesh rotate with WheelCollider

$
0
0
So this may be a simple question, but I really can't seem to figure it out. I searched all over google for this, but alot of them were just linking to youtube tutorials, which showed some script from another tutorial, and messed the whole thing up, by using another script.. So I have 4 wheel colliders, which I can turn. Now I want the meshes, to turn with the wheel colliders. This is my hierarchy: Vehicle: WheelMeshRightFront WheelMeshLeftFront WheelMeshLeftBack WheelMeshRightBack WheelColliderRightFront WheelColliderLeftFront WheelColliderLeftBack WheelColliderRightBack So this should be all set up. I'm simply asking for some hint to, how to turn the mesh with the wheels? I've read something about using eularAngles, and then set it on the mesh, but I just can't figure out how you do that.. Any answers to this? Feel free to ask about anything related to my scripts or setup. Thanks!
Viewing all 490 articles
Browse latest View live


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