|
Hi there ,Im begging on my knees now ,all I want is to make the Unity Car Tutorial Function properly ,as in when no keys are touched the car should stop but it doesnt :( Matthew A said that this piece of code should fix the problem . There is also a bug in Car.js which I think exacerbates this problem (the car accelerates when the throttle isn't being pressed). I believe the logic there should be something like this instead: if (throttle == 0) { // Mathf.Sign returns 1 when a value is 0, (also happens in HaveTheSameSign) // this causes inappropriate acceleration unless we check whether throttle is 0 first... :-/ } else if (HaveTheSameSign(relativeVelocity.z, throttle)) { if (!handbrake) { throttleForce = Mathf.Sign(throttle) * currentEnginePower * rigidbody.mass; } } else { brakeForce = Mathf.Sign(throttle) * engineForceValues[0] * rigidbody.mass; } Has anybody any Idea where to put this piece of code ,I am tearing my hair out just trying to get this demo to work ,please please please someone help me out ,I have been trying to sort this out for months but noone seems to know the answer :(
(comments are locked)
|
|
Well as you are desperate I've given it a go. Looks to me like there isn't much friction going on, not enough to overcome something in the simulation that keeps it rolling. I guess the answer is either to do something with the forwardFriction of the WheelCollider (but Googling implies that there might be problems here) or to apply some level of braking when there is no throttle. Here's a stab at that: A fine answer, thumbs up to you
Jun 04 '12 at 11:07 AM
hatchnet
(comments are locked)
|
|
Hey there Mike thanks for the reply :) can you tell me where I drop this into car.js please mate,I have tried different places but keep getting this error ? Assets/Standard Assets/Scripts/Car.js(595,10): BCE0089: Type 'Car' already has a definition for 'ApplyThrottle(boolean, UnityEngine.Vector3)'. ps im writing for Android if that makes any difference ? Just find the line function ApplyThrottle and totally replace that routine It's somewhere near line 510
May 26 '12 at 07:46 PM
whydoidoit
(comments are locked)
|
|
Im redownloading the untouched car tut and ill get right back to you :) ,fingers crossed :) silly question im on latest unity 3.5etc would that make any difference ? Just a note: you shouldn't post answers unless you are answering things :) Just use the comments - it messes up your accepted score too! Well I'm running 3.5.2 and that code made the car stop for me :) You can adjust those 20000 numbers to have less of an effect/more of an effect etc. I'm not sure this is the ideal way to have it work - the car model is doing stuff like Engine braking etc, but I couldn't make it stop that way...
May 26 '12 at 08:32 PM
whydoidoit
lol ,have been all over the place with answers instaed of comments lol :P ,but once again thank you :) this was literally driving me nuts lol :)
May 27 '12 at 04:40 AM
mak
Android ^^ ,it was trying to make the game run on Android/I-phone all along ,I feel like such a fool now lol ,ah well back to the drawing board I guess :p . Basically when I switch platform for Android the car rolls ... Im beginning to think its all just not possible :(
May 27 '12 at 06:12 AM
mak
(comments are locked)
|
|
Woot ,dont take this the wrong way but I LOVE YOU !!!!!!!!!!!!!!!!!! Absolutely perfect THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Just flag is as answerer and I'll be happy :)
May 26 '12 at 08:41 PM
whydoidoit
Perferably flag me as answering it not yourself ;) !!!!!
May 26 '12 at 08:46 PM
whydoidoit
Don't worry about it!
May 26 '12 at 08:47 PM
whydoidoit
(comments are locked)
|
