#Problem trying to simulate car engine and transmission
1 messages · Page 1 of 1 (latest)
Transmission:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Transmission : MonoBehaviour
{
public float[] gearRatios;
public AnimationCurve[] torqueCurveLookup;
public float[] maxTorque;
public int currentGear;
public float currentGearRatio;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
currentGearRatio = gearRatios[currentGear];
if (Input.GetKeyDown(KeyCode.E))
{
if (DoesGearExist(currentGear + 1))
currentGear++;
}
if (Input.GetKeyDown(KeyCode.F))
{
if (DoesGearExist(currentGear - 1))
currentGear--;
}
}
bool DoesGearExist(int proposedGear)
{
if (proposedGear > gearRatios.Length - 1 || proposedGear < 0)
{
return false;
}
return true;
}
}
All of the data I put in is based off of a 1990 corvette
To clarify: The problem I have is specifically with the engine losing power as it goes to higher gears, being less and less able to move itself forward. Here is a video:
I was holding full throttle the whole time
Every time you hear the engine go to a different pitch rapidly, I shifted down gears
you're decreasing the torque
@sullen flume based on your pfp and name I feel like you understand cars more than me, so perhaps I am misunderstanding
an engine outputs it's maximum torque at a specific rpm
why do you need so many torque curves
one for each gear
i ended up using one torque curve to simplify it
As I suggested
Problem solved? Or no
Partially
Not really actually
It’s a different problem now
Too much rpm
But it’s much less annoying
Problem solved? Or no