resetting a mg's angle after rotation

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

resetting a mg's angle after rotation

Post by wacko »

Binding a mg to a platform and then rotating the platform causes the mg to have a changed direction, i.e. when it is released, it jumps to somewhere and the MaxYawOffset isn't centered anymore, both depending of how much the platform did rotate.
So, how could I let the mg know about it's new center direction? I tried something like

Code: Select all

$mg.yawcenter = $platform.angle
but this seemed to not work...
User avatar
Kalti
Major
Posts: 325
Joined: Sun Mar 16, 2003 11:46 am
Contact:

Post by Kalti »

It's not my place... I know :)

But can't you spawn a new mg after the release, perhaps it will take the mg.yawcenter command only that way ?
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Kalti wrote:It's not my place... I know :)

But can't you spawn a new mg after the release, perhaps it will take the mg.yawcenter command only that way ?
errrm don't think so. it's visible and usable all the time before, during and after the rotation

But I just found out it's probably not "$mg.yawcenter = $platform.angle" but rather "$mg yawcenter $platform.angle", so there's hope again 8-)
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

"$mg yawcenter $platform.angle" is working. but this does just the yawcenter. When I release the mg, it snaps to some other angle, like before.

To explain maybe a bit better: What I need is a mg mounted on a rotating platform. For the player who is also standing on this platform, it should behave like any mg (relatively).
User avatar
Kalti
Major
Posts: 325
Joined: Sun Mar 16, 2003 11:46 am
Contact:

Post by Kalti »

Whenever the mg is released it should return with the barrel pointing exactly outwards from the center of the platform.

Perhaps binding the mg to another brush (maybe even an origin) and counter-rotate that (in perspective to the platform) so the rotation is being cancelled out ?
Last edited by Kalti on Mon Feb 07, 2005 10:17 pm, edited 1 time in total.
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

mmm, don't think that'll work. and a normal mg wouldn't return to the center, it would stay just where u dropped it...
I did a little demo mapwhere a mg is on a rotating platform. Once u did grab the mg and after a bit of rotation let it go, u'll see the problem.
User avatar
Kalti
Major
Posts: 325
Joined: Sun Mar 16, 2003 11:46 am
Contact:

Post by Kalti »

Ah... noticed it.

It will even throw me off the platform when I release the mg.

Btw. the mg will rotate a full 360 when in the hands of the player... is it ment to do that or does that has to be defined ?
Image
User avatar
Kalti
Major
Posts: 325
Joined: Sun Mar 16, 2003 11:46 am
Contact:

Post by Kalti »

Well... I tried it...

Code: Select all

main:
	level waittill prespawn

	//*** Precache Dm Stuff
	exec global/DMprecache.scr
	level.script = maps/dm/mgrotation.scr

	level waittill spawn

	thread prep

end

prep:
$mg bind $counter_rotation
$bipod bind $platform
$counter_rotation bind $platform
$platform rotateY 5
$counter_rotation rotateY -5
end

Now, I'm no scripter... so I probably messed up somewhere, but it seems to work...

User-mgcounter_rotation.pk3

*EDIT: too bad... the mg will drop where you release it but then it will rotate on itself, and that's no good.
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Kalti wrote:Btw. the mg will rotate a full 360 when in the hands of the player... is it ment to do that or does that has to be defined ?
I thought it to be confusing enough already. :wink: the mg ought to have a k/v of maxYawOffset/60. This would allow a 120deg field. This Yaw though is calculated from a YawCenter, which is supposed to be the angle of the untouched mg. I thought it to be quite simple: $mg.angle and YawCenter, I thought, are always the same as $platform.angle, atleast in this map. Well, it isn't. :cry:

Code: Select all

main:
	level waittill prespawn
	exec global/DMprecache.scr
	level.script = maps/dm/mgrotation.scr
	level waittill spawn
	thread prep
	thread rot
end

prep:
$mg bind $platform
$bipod bind $platform
$platform rotateY 5
end

rot:
while(1)
{
$mg yawcenter $platform.angle
iprintln_noloc $platform.angle " | " $mg.angle
wait .5
}
end
In this script, the yawcenter keeps correct. (I have no $counter_rotation in this map.)
But the $mg.angle is (as I can read by the iprintln) completely different to $platform.angle and - weirdest thing - it changes in a different speed than this. So the question is: What IS $mg.angle?? Where's it coming from? And what's the name of the mg's angle I must use??
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

angles

Post by tltrude »

Maybe you should try "angles". There are also these commands.

----------------------------------------------------------------
GetLocalYawFromVector

Turn a worldspace vector into a local space yaw
----------------------------------------------------------------
----------------------------------------------------------------
angles_toforward( Vector angles )

Returns the forward vector of the specified angles
----------------------------------------------------------------
----------------------------------------------------------------
vector_toangles( Vector vector1 )

Returns vector1 converted to angles.
----------------------------------------------------------------
----------------------------------------------------------------
forwardvector

get the forward vector of angles
----------------------------------------------------------------
Tom Trude,

Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

if I used the iprintln line like

Code: Select all

iprintln_noloc $platform.angle " | " $mg.angles
I get better results for the mg, indeed: The y-value is rather the same as $platform.angle. But just as long as I don't use the mg. As soon as I use and drop it, it fetches it's angles from dunno where.
Could/would u give it a try, please?
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

maybe some basic information atleast?
what is and/or what is the difference between $mg.angle and $mg.angles[1]?
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

i see.. you ant the yaw limitations to change as the platform spins.... with a platform like that, wouldnt it be hard for the game to find what angle its at.. being it has do many edges...?
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

actually you could bind a simpel script_object to the platform and take it's angles :P

angle has nothing to do with sides, it's where the game considers the front to be.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

test

Post by tltrude »

I think your problem is that you are not resetting the guns "pitch" and "roll", so it uses the old values. The old values can be read by printing the gun's "angles" when it is not in use. If you print the platform's "angles", The pitch and roll (first and last numbers) should be 0 all the time. The center number of "angles" is the yaw (left, right).
Tom Trude,

Image
Post Reply