Page 1 of 1

Gun Direction

Posted: 09 Apr 2010, 04:07
by SanadaUjiosan
So I'm aware of and have used the whole Weapon Direction thing, how you can control which direction an attack cone is. But I've run into another problem.

Basically, my turret that I want to be able to swivel 360 degrees is pointing behind the unit when in default mode. But when I tell it to shoot, it turns the opposite direction, barrels pointing away from target. How can I get this to aim properly and keep my turret pointing backwards by default?

Re: Gun Direction

Posted: 09 Apr 2010, 04:24
by Guessmyname
Invert the heading in the aiming script (in the 'turn' command that aims the turn, tell it turn to (0 - heading) instead of just heading)

Re: Gun Direction

Posted: 09 Apr 2010, 05:07
by SanadaUjiosan

Code: Select all

	function script.AimWeapon1( heading, pitch )
		Signal(SIG_AIM)
		SetSignalMask(SIG_AIM)
        	Turn(flakturret, y_axis, (0 - heading), math.rad(90))
        	Turn(barrel, x_axis, -pitch, math.rad(50))
        	WaitForTurn(flakturret, y_axis)
        	WaitForTurn(barrel, x_axis)
		StartThread(RestoreAfterDelay)
		return true
	end
All that got me was my turret stopping at a 90 degree angle from it's target, and shooting from the side.

Re: Gun Direction

Posted: 09 Apr 2010, 06:39
by Guessmyname
Well, it's getting closer at least. Try 90 - heading or 90 + heading (if one fails, try the other), depends whether it's off 90 degrees clockwise or anticlockwise.

Re: Gun Direction

Posted: 09 Apr 2010, 07:09
by SanadaUjiosan
Hmm, okay. This won't create any wonky side-effects will it?

Re: Gun Direction

Posted: 09 Apr 2010, 07:39
by Evil4Zerggin
I would turn the barrel forward on the model, and turn it backwards in Create() and RestoreAfterDelay().

Re: Gun Direction

Posted: 09 Apr 2010, 07:40
by Forboding Angel
The wonky side effect was created when you did it rong in upspring.

Re: Gun Direction

Posted: 09 Apr 2010, 18:33
by SanadaUjiosan
I don't see any problem with wanting a turret to be pointing backwards.

That sounds like a pretty good fix Zerggin, I'll give that a try.

Re: Gun Direction

Posted: 09 Apr 2010, 20:28
by Forboding Angel
It would be the y orientation of your turret.

If you rotated the base and then neglected to hit "Apply Transform" that would explain a lot. If you wanna post up your model, I'll maek fixie.

It's not really good to have to fix a model with scripting. It's better that the model is right in the first place.

Re: Gun Direction

Posted: 09 Apr 2010, 20:36
by SanadaUjiosan
Forboding Angel wrote:It's not really good to have to fix a model with scripting. It's better that the model is right in the first place.
I agree. Here's the model and texture, just so it's easier to see what's going on. The turret now is pointing to the back of the unit.