Author Topic: Autoturret on vehicle  (Read 1980 times)

I was trying to create an autoturret (to mount on a vehicle).
However, since it is mounted on a vehicle, it doesn't aim very well at the moment.

Is this fixable (apart from Space Guy's script (i allready PM'd him about it))?
Or am i forgeted?

The vehicle it is mounted on is a wheeledvehicle.

Thanks in advance.

Why does %bot.setAimObject not work?

They'll aim at weird offsets if the vehicle points anywhere but north.

What would happen if i mount the turret on a invisible bot that is mounted to the vehicle?

I don't know the answer but you should be able to try that yourself.

I don't know the answer but you should be able to try that yourself.
Yeah i am.
Thanks for your advice anyhow.

I was asking that because you know, maybe someone tried it.
I'll try it and post the results.
Though i guess it will not help a thing.

Set the invisible bot to always face north. Try and find some sort of hack so it can pivot instantly. That may actually work, but I think it's rotation will offset the actual turret and that will be no good.

Set the invisible bot to always face north. Try and find some sort of hack so it can pivot instantly. That may actually work, but I think it's rotation will offset the actual turret and that will be no good.
Hmm. I see.
Interesting idea. Will use it if i encounter such a bug.
However, i cannot do it now sadly.
Bit too busy. :C

Getting the "invisible" bot to always face north would use exactly the same method as just aiming the bot with the AIConnection. Plus it wouldn't work well if the vehicle is on a slope.

You could try hacking it to remove the weird offset then using setAimPos or something. But I'm going to guess the offset is random and something is broken :S

Well then how did Space get his to work?

They'll aim at weird offsets if the vehicle points anywhere but north.
Couldn't you offset the aim then to counteract the offset mentioned above?

Well then how did Space get his to work?
Well i have to ask Space Guy for permission to post what he sended me as information when i asked about it...
Couldn't you offset the aim then to counteract the offset mentioned above?
That is an idea but...
But I'm going to guess the offset is random and something is broken :S
Most likely.

i'm thinking that the aiming command for the bots is offset by the rotation of the vehicle
if that is true... then why not find the rotation of the vehicle and mix it with the aiming?
i'm probably so wrong :D

For reference for everybody else:
Basically, the default "setMoveDestination" and "setAimLocation" do not work when in a vehicle. To make a bot look in the right directions, you have to create an AIConnection object and have it control the bot - this is a fake client which you can set instructions like "turn right" instead of "look at this point". Unfortunately to control this right you need to update it on a tick/schedule very quickly, and do trigonometry to find angles and such.

The problem with them driving is that you cannot get the current wheel direction of the vehicle. This means you cannot tell the difference between the wheels facing straight forwards and the wheels off to the side - trying to steer left and right depending on the main vehicle's rotation causes it to swing wildly.

My last implementation caused lag when more than 10-15 bots existed at a time, but that'd be fixable by making it only use the special aiming when in a vehicle, otherwise using the automatic functions/not having the AIConnection control it.