Gun Direction

Gun Direction

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Gun Direction

Post 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?
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Re: Gun Direction

Post 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)
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Gun Direction

Post 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.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Re: Gun Direction

Post 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.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Gun Direction

Post by SanadaUjiosan »

Hmm, okay. This won't create any wonky side-effects will it?
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: Gun Direction

Post by Evil4Zerggin »

I would turn the barrel forward on the model, and turn it backwards in Create() and RestoreAfterDelay().
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Gun Direction

Post by Forboding Angel »

The wonky side effect was created when you did it rong in upspring.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Gun Direction

Post 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.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Gun Direction

Post 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.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Gun Direction

Post 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.
Attachments
AA Truck.rar
AA Truck
(94.86 KiB) Downloaded 11 times
Post Reply

Return to “Game Development”