Jump to content

Turret Rotation


Kronos
 Share

Recommended Posts

I have a vehicle which has a turret base attached to it which can rotate locally around its y axis. A barrel is attached to this turret base that can move locally in the x axis but has an upper and lower limit on how far it can rotate. The vehicle will be travelling over uneven terrain.

 

My question is how can I make the gun turret point towards a certain point, eg an enemy vehicle or a specific point in space.

 

When i was using Blitz3d I used Deltayaw and Deltapitch for this which worked fine, but we do not have these functions in Leadwerks. I tried using the Deltapitch/yaw functions from minib3d but they don't work.

 

I have also been trying to use PointEntity but it appears to only work using global angles and not local ones. The turret base must only rotate around its own y axis and the barrel must only rotate around its own x axis.

 

Does anybody have any suggestions as to how I can achieve the result I am after?

intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit

Link to comment
Share on other sites

This seems to do the job for horizontal and vertical aiming.

 

 Local t:TVec3=TFormPoint(Vec3(0,0,0),enemytarget.chassis,chassis)

       dYaw = -ATan2(t.x,t.z)
dPitch =-ATan2(t.y, Sqr(t.x*t.x + t.z*t.z))

mRotate(turret1,0,CurveAngle(dYaw,entityrotation(turret1).y,10.0/AppSpeed()),0)
mRotate(barrel,CurveAngle(dPitch,entityrotation(barrel).x,10.0/AppSpeed()),0,0)

 

never really understood TFormpoint and TFormVector before but its becoming clearer.

 

Thanks Josh for pointing me in the right direction.(haha unintentional pun)

intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...