Kronos Posted October 26, 2011 Share Posted October 26, 2011 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? Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit Link to comment Share on other sites More sharing options...
Josh Posted October 26, 2011 Share Posted October 26, 2011 There's an example like this in the Games/Driver script. The turret will keep pointing towards the camera direction, along it's own rotation axis. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Kronos Posted October 26, 2011 Author Share Posted October 26, 2011 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) Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit Link to comment Share on other sites More sharing options...
Recommended Posts
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.