WheeledVehicle updateMove
by Ronald J Nelson · in Torque Game Engine · 08/29/2007 (5:32 pm) · 11 replies
IS there someway to tell in WheeledVehicle's update move if you have selected to go forward or backard?
#2
Has anyone done something like this they would share?
08/29/2007 (11:58 pm)
Basicaly I just need to be able to tell when the vehicle is going backwards. I have been testing several different methods with little success.Has anyone done something like this they would share?
#3
08/31/2007 (6:05 am)
I could be wrong, but there should be something like %obj.getVelocityVec() or similar script function (derived from shapeBase class?) that returns vector of where the object is moving. If it's negative - then it going backwards.
#4
08/31/2007 (11:14 am)
You'd need to test the forward-facing vector versus the momentum vector, using mDot. A negative value means it's closer to going backwards than forwards. A -1 value means it's going precisely backwards.
#5
I used this and it works great:
08/31/2007 (10:43 pm)
Actually figured this one out already on my own (It really does happen now and then, really it does!!).I used this and it works great:
Point3F vel = Parent::getVelocity(); F32 speed = vel.len(); if(move->y < 0 && speed < 5.0f) inReverse = true; else inReverse = false;
#6
09/01/2007 (8:08 pm)
What function did you run it from?
#7
09/02/2007 (12:05 am)
UpdateMove
#8
Or if the car is moving backwards by more than 5 metres/sec?
Or maybe I misunderstood what you were trying to do..
09/02/2007 (4:09 am)
Ron, what about if the vehicle is sliding around a corner and goes into a spin, while the player is still trying to accelerate forwards? - I don't think your code would work there. Or if the car is moving backwards by more than 5 metres/sec?
Or maybe I misunderstood what you were trying to do..
#9
As for the spin, worst case I have seen is realistic. The car goes into a spin, the Bot perhaps pulls a cookie, straightens it out and moves on.
Since I am also using an adjustable friction per terrain, most of the time the Bot does a nice drift around the corner.
I have max speed cap set up for each of my gears, to include reverse. With that in mind if the vehicle does lose control, it automatically shifts down due to the speed of the vehicle, effectively allowing bots to regain control. In reverse, they have no porblem steering either.
Been testing this pretty extensively with jumps and insanely rough terrain. Everything works perfectly.
09/02/2007 (7:50 am)
Actually Sam my code is a highly modified version of the Engine/Transmission resource. This system works flawlessly with it. As for the spin, worst case I have seen is realistic. The car goes into a spin, the Bot perhaps pulls a cookie, straightens it out and moves on.
Since I am also using an adjustable friction per terrain, most of the time the Bot does a nice drift around the corner.
I have max speed cap set up for each of my gears, to include reverse. With that in mind if the vehicle does lose control, it automatically shifts down due to the speed of the vehicle, effectively allowing bots to regain control. In reverse, they have no porblem steering either.
Been testing this pretty extensively with jumps and insanely rough terrain. Everything works perfectly.
#10
09/02/2007 (9:48 am)
Ron - I didn't realise this had anything to do with bot driving, I thought it was purely a question about whether a car was moving backwards. If it's going good, that's fine ;-)
#11
09/02/2007 (1:18 pm)
Well the need for it was based off something wrong with the code that bots I have showed me. In reverse had no limit to how fast it could go. I was having bots travelling in reverse at ridiculous speeds.
Torque Owner Demolishun
DemolishunConsulting Rocks!