Coucoul38 1 Posted May 2, 2023 Hi, I'm changing the player's vehicle with a script, and I want the turret of the new vehicle to face the same way as the old one did. Before changing the vehicle, I'm getting the old turret's aiming position with this: _turretDirection = eyePos vehicle _x; And to make the new turret rotate I tried this : _veh unitTurret(_x) lookAt _turretDirection; and this: _x lookAt _turretDirection; but it doesn't work. Share this post Link to post Share on other sites
mrcurry 496 Posted May 3, 2023 14 hours ago, Coucoul38 said: I want the turret of the new vehicle to face the same way as the old one did. This can be tricky to get right... lookAt only works on AI so you would need to replace the player with an AI to turn the turret, same with doWatch which I prefer. Neither of them is foolproof though. Sometimes the AI will just refuse to turn it, or go back to "neutral" directly after finishing the turn. Turrets can be turned and elevated through script by animating the correct part. Main problem with this approach is that the names and parameters of the anim will likely vary between vehicles, especially if you're using modded content. Afaik there's no onesize-fits-all solution for this. There's also different vehicle sizes, turret layouts and traversal limits to consider. When the new vehicle is created you would have to guarantee that the aim direction aligns perfectly with whatever the player is looking at or the experience may be quite jarring. My recommendation: Just fade to black while you change vehicles. Share this post Link to post Share on other sites
POLPOX 778 Posted May 3, 2023 https://community.bistudio.com/wiki/lockCameraTo Even though it's “camera” in it this is the way. 2 Share this post Link to post Share on other sites
mrcurry 496 Posted May 3, 2023 1 hour ago, POLPOX said: https://community.bistudio.com/wiki/lockCameraTo Even though it's “camera” in it this is the way. "Since Arma 3 2.08 the command also works with non-stabilized turrets (such as main turret of a tank)." - Awesome! Share this post Link to post Share on other sites
Coucoul38 1 Posted May 3, 2023 Well I tried to do it, but it is not instantaneous, and most importantly the eyePos function actually returns the position of the optic ? So I need to find a function that returns the coordinates where the player is looking at. Either that or find a way to rotate the turret so that it aligns with a vector that I can get using this: eyeDirection vehicle _x Share this post Link to post Share on other sites
mrcurry 496 Posted May 4, 2023 14 hours ago, Coucoul38 said: So I need to find a function that returns the coordinates where the player is looking at. screenToWorld [0.5, 0.5] 1 Share this post Link to post Share on other sites
Coucoul38 1 Posted May 5, 2023 On 5/4/2023 at 11:07 AM, mrcurry said: screenToWorld [0.5, 0.5] Thanks, this works perfectly. Do you know if it's possible to speed up the turret traverse so that it's almost instantaneous? Share this post Link to post Share on other sites
mrcurry 496 Posted May 5, 2023 I just lost my HDD with arma on it so can't check but here's a couple of options: setAnimSpeedCoef allows you to change animation speed for units but don't think it works for vehicles. If it does you could speed up the animation that way. setTurretLimits allows you to limit the the range of turrets, if you get the pitch and yaw to target you could limit the turret to the desired direction and then reset the limits when the target is reached. In theory the view should "snap" to stay within the limits, not sure if it'd work but worth a shot. Share this post Link to post Share on other sites
avibird 1 154 Posted May 5, 2023 I used this for arma2 worked great however never used it for arma3 still may work or you can tweak the commands. Share this post Link to post Share on other sites