![]() Sorry for the long-winded post.In this post, I will provide step-by-step instructions on how to create a simple isometric camera and character controller in Unity. M_CurrentTorque = m_FullTorqueOverAllWheels Īs I say that is just standard Unity Assets code, but particularly in the ApplyDrive function i see the forward variable that I think will be useful (or hope :))Īny help on the best way to approach this kind of problem is massively appreciated. If (m_CurrentTorque > m_FullTorqueOverAllWheels) M_CurrentTorque += 10 * m_TractionControl M_CurrentTorque -= 10 * m_TractionControl crude traction control that reduces the power to wheel if the car is wheel spinning too muchįor (int i = 0 i = m_SlipLimit & m_CurrentTorque >= 0) if it wasnt slipping stop all the audio if they do it can lead to some strange audio artefacts avoiding all four tires screeching at the same time M_WheelColliders.motorTorque = -m_ReverseTorque*footbrake įor (int i = 0 i = m_SlipLimit || Mathf.Abs(wheelHit.sidewaysSlip) >= m_SlipLimit) ThrustTorque = accel * (m_CurrentTorque / 4f) įor (int i = 0 i 5 & Vector3.Angle(transform.forward, m_Rigidbody.velocity) 0) Private void ApplyDrive(float accel, float footbrake) M_Rigidbody.velocity = (m_Topspeed/3.6f) * m_ M_WheelColliders.brakeTorque = hbTorque įloat speed = m_ Var hbTorque = handbrake*m_MaxHandbrakeTorque If (m_GearNum > 0 & f upgearlimit & (m_GearNum 0f) M_CurrentTorque = m_FullTorqueOverAllWheels - (m_TractionControl*m_FullTorqueOverAllWheels) įloat f = Mathf.Abs(CurrentSpeed/MaxSpeed) įloat upgearlimit = (1/(float) NoOfGears)*(m_GearNum + 1) įloat downgearlimit = (1/(float) NoOfGears)*m_GearNum M_WheelMeshLocalRotations = new Quaternion I'll post the code here in case it helps: (Btw, its in the ApplyDrive method that im actually thinking the values i need are already there) I need some solid maths revision to get anywhere near calculating it myself and I just have a creeping feeling that half (if not more) of the work is already done for me inside this Unity Car Class. Most of the road is a nice straight road but there are some long bends too. I am using the Unity Standard Car and I see in it's code that it has some math and uses the variable "forward", but im not sure how i can obtain a copy of that value, send it to my GameManager or Player script so that I can calculate where to put the obstacles etc onto the road exactly. I think it must be calculated using the rotation, previousRotation, position, previousPosition and thats the route ive been exploring but i have failed to get anywhere and now my code is in a right mess. If the players car is moving around a bend at 45d angle, then it would appear to be travelling much slower by my calculation than it actually is. So the way i normally calculate the MPH doesnt work I think, as it only works on 1 axis. I can arrange all of this normally myself, but here's the thing, I can only do it on a straight road.I want to proedurally generate the gameObjects (such as a ramp in the road, or an enemy at the side of road, or a cow in road for example).Ĥ.I also would like a MPH counter (speedometer) I'm using the Unity Standard Assets Car with some very small modifications to the control system only so far. Of course there are going to be obstacles and enemies trying to stop you. Its a driving game where you have to drive along one long road until you get to the end. Here is the version of my current problem (but this is linked ot many other aspects of how my game will work, for example when I want to spawn a game object directly in front of the player for example): Back when i coded in 2d only this was often a stumbling point for mine even when only dealing with an x and y axis. Im having some trouble visualising how the maths works for this particular problem.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |