it’s not just about spinning direction, that function assumes the vehicle going forward, you should detect the case when the vehicle’s velocity is not aligned with the vehicles forward direction(you can use a dot product) and possibly invert the forward vector.
You mean something like what you did here?:
FVector velDir = mVehicle->getVelocityDir();
FVector dir = mVehicle->getForwardDir();
float sign = FGearUtility::Sign(FVector::CrossProduct(dir, velDir).Z);
I tried, better but still fails. I found adding this one to the condition helps:
float rollZ = FGearUtility::getWorldTransform(mBody).Rotator().Roll;
But still fails in a few frames, enough to make the car get stuck.
There is no other Rotation variable that already gives always the correct values? I tried mLocalVelocity.Y and other lateral stuff but all them fails in one or other scenario.
well you may not be able to get a result that works right away, find the failing spots and make adjustments as needed. you just need to debug the code to see what numbers are failing.
I realized the cars in the new SandBox 2 all them have the Mx/My/Mz Momentum Scale to 0.0.
But the original ones, Mx/Mz are 1.0, and for (My)Roll it can be from 0.2 to 1.0 in some cases.
I cant find any behaviour difference in Mx/Mz, but (My)Roll makes the car like more traction/friction.
Any reason for that change in new cars? or just to make more slide/drift?
if you read the documentation it says:
All tire models generate Fx, Fy and My. Mx and Mz are only generated by MF6.1 tire model.
there is no specific reason for their values, if you try a very large value for My you can observe that the vehicle will rear up.
How i get LateralFriction or LateralScale,etc… per axle?
Only get working this:
mAxle->getWheelOptions()->getLateralFriction();
mAxle->getWheelOptions()->getLongitudinalFriction();
Or if they are axle*wheel:
mVehicle->getAxle(0)->getLeftWheel()->getLateralSlip();
But when the get/set is only available for axle, im unable to find how ¿?
In blueprints i see how:
But via code, tried FrontWheelOptions, or WheelOptions0 or similar but nothing worked. Checked other .cpp but cant find any reference how i should do that. ¿?.
How do you make it so the fgear camera cant go through walls and has a collision
in the project settings there is a clip value. change that.
wheel options are per axle, shared between wheels.
after doing any modification, you should call Axle.applyWheelOptions function.
wheels also store local values too but they can’t be read from BP right now, you can only modify them per wheel like Wheel.setLatFriction, if you want to access them per wheel you need to add your own BlueprintCallable getter functions.
I was feeling something wrong with the braking and started to debug.
I tried to disable/set 0 anything that affect to brake/torque reduction:
ABS: 0
BrakeTorque on each wheel: 0
DiffStrenght: 0
Rolling Resistance: 0
Aerodynamics: 0 on everything
— Disabled On FGearWheel —
//apply brake torque
mSpeedOverflow
And still, on press braking, it reduces the torque in some way.
It seems the problem is when Accel and brake is pressed.
Without accel, if i press brake, nothing changes in car behaviour.
But with accel pressed, if press brake, even with all that disabled/0, the torque decreases.
What im missing?
Edit: I think i found the problem:
In 1.81 & 1.7. there is “* mRadius” then this problems happens.
mFeedbackTorque = (FMath::Abs(currentForce) + absLngFriction) * mRadius;
In 1.62. There is a very minimal change, torque/lngforce less erratic, but no torque decrease.
mFeedbackTorque = FMath::Abs(mWheelTorque) + absLngFriction; // 1.62
@lazybitgames I am working on a vehicle pool system for my open world game. When using fgear vehicles, the physics body is always ticking even when “asleep” so I get an error “attempting to move a simulating body” when trying to pool a vehicle at 0,0,0. I have tried manually putting the body to sleep, disabling tick, disabling gravity but when those are reenabled, the vehicle body it not at its default suspension position. It works fine with chaos vehicles but I am having a difficult time with fgear vehicles. Any recommendations on how to achieve the above?
the vehicle body is not at its default suspension position.
so if I understand you correctly, you mean when you spawn a vehicle from the pool, it falls or jumps a little instead of just spawning at its resting suspension position. if that’s the case I guess I would implement a function that runs at the first frame only and adjusts the suspension so that it prevents this behavior. instead of that may be you can try running the vehicle.substepTick function once just after the spawn so that the suspensions are adjusted automatically, this should work in theory. you just need to make sure you spawn the vehicle at the correct Z position so that it would be at its resting state.
in the project settings? I dont see it
@lazybitgames So, what about this braking bug? The formula is wrong or this is the intended behaviour? Ive been testing and feeling is better, mostly happens on 1st gear/low speed.
To be clear is on FGearWheel.cpp on this:
// Automatically avoids low speed jitters
I also changed “if (mBraking > 0.0f)” to (aBraking > 0.0f) , aBraking is:
mVehicle->getStandardInput()->getBrakeFinalInput();
That function is not blueprint callable correct? Because I cannot find it in the graph.
it’s a speculative formula but it may not be correct, try the one below:
mFeedbackTorque = FMath::Abs(currentForce) + absLngFriction * mRadius;
Nope, also decreases the wheel torque a lot when braking while accel and lot of erratic low/high variations, like braking/accel fighting.
If you have any other ideas or code let me know, will keep the v1.6 from now.
Bug Report:
In this situation:
- Using custom inputs (FGear Standard Input Disabled)
- Using sequential or manual gear change, (Transmission > Auto Change Disabled)
When changing from first gear to reverse or from reverse to first gear with the throttle still pressed, the brakes get stuck (brakes activated automatically by the plugin), you have to press the brake once to release it. This problem is very annoying when you need to change gears quickly and drive off, but the vehicle remains stopped because the brakes were involuntarily activated.
Note: If you are using pedals on a combined axis, the brake is released as soon as you release the throttle, if you are using separate axes, you need to press and release the brake once to unlock it.
Plugin vr 1.8.1
Tested on UE 4.27 and UE 5.3.2
first of all it is recommended to use standard input even if you want to implement your own custom input system, without it replicating inputs won’t be possible.
in your case did you try setting “Reverse Brake Speed” to zero.
@lazybitgames jusy following up on this. Also is there an implementation on Enhanced input in the FGear example? The documentation is unclear on how to implement.