I have a custom vehicle that is the game character, however to make sure it turns correctly for reversing and moving forward I need to reverse the direction of the turn when the vehicle is reversing, to simulate what the tires would do ( It's not turning with tires, only forces).
However, I don't know how I would get the speed (and hence 'negative' speed) of the vehicle to tell the game to reverse the turning; the game character speed data source is only for the bike, and the force for moving the vehicle forwards and backwards can be negative whilst the vehicle is still moving forwards.
I've thought about getting the rotation of the tyres which would show this, but I don't know if that's possible.
TL;DR How would I get the direction of movement for a custom object?
(edit: it would also be nice if I could get the speed of the object, not just the direction, for other purposes, if that's not too much...)
Any help? Thanks in advance.
If you are already using forces to move your vehicle can't you just glue a directional force to the front of it pointing left, then tie the force value to the horizontal axis of the left controller stick.
A negative value will then turn right, and it will turn correctly in reverse. You will probably need a two input operator to increase the stick value to get a sensible force, but you probably knew that already.
I'd already done everything you said; what this does is turn the vehicle clockwise/right if you are pressing right on the thumbstick, and vice-versa for left.
There are two problems with this: one, the vehicle will turn when stationary, which it shouldn't do. Two, when reversing, the vehicle will turn clockwise/right when you press right - when it should be turning anticlockwise, as this is what happens with tires, and thus feels more natural. A clearer way of describing why this is wrong is that you are able to perform a 3-point turn whilst only holding right, which in a normal vehicle is impossible.
For the same vehicle I have another problem - my hit detectors for the tyre and ground aren't saying when they're disconnected, so you can still move when upside down or in water. It's not as big a problem, but I'd also be grateful if someone could help here as well if that's not asking too much.
Again, thanks in advance.
The easiest way to solve all these problems is to use motors rather than forces to move your vehicle. It's a lot harder but the end result is much better.
Try the tutorials linked in my sig for more info.
Hmm, I'll give that a try then if I can't get anything else to work.
Thanks for the tutorials, though they recommended to use forces for cars as well
Edit: okay, the tyre's rotation can be found with angle Z from the object info. Now, I need to find a way to compare the angle between 2 ticks; I imagine this would be done be 'saving' the data value, then in the next tick saving the same source, then comparing the two and using that.
However, I don't know (again) how to 'save' or freeze a variable data source value...any help here?
Not the one I wroteOriginally Posted by RedDagger
I'm not sure of the method you are using but how I would save the data like you suggest is to have 2 set value events which both have their value linked to the Z angle of the tyre, and targeting 2 separate variable data sources.
Send an impulse to the first Set value event, then pass the impulse to a delay filter set to 1 tick, then on to the next set value event.
The result should be you end up with two variable data sources with the Z angle of the tyre in them 1 tick apart, which you can then compare.
Yay, this works! Thanks very much!
Yeah, I just assumed the first I saw was the only one...there's probably a third I overlooked.