Page 1 of 2

resetting a mg's angle after rotation

Posted: Mon Feb 07, 2005 4:27 pm
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...

Posted: Mon Feb 07, 2005 5:07 pm
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 ?

Posted: Mon Feb 07, 2005 5:09 pm
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-)

Posted: Mon Feb 07, 2005 5:41 pm
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).

Posted: Mon Feb 07, 2005 10:01 pm
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 ?

Posted: Mon Feb 07, 2005 10:14 pm
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.

Posted: Mon Feb 07, 2005 10:26 pm
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 ?

Posted: Mon Feb 07, 2005 10:49 pm
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.

Posted: Tue Feb 08, 2005 12:04 am
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??

angles

Posted: Tue Feb 08, 2005 7:23 am
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
----------------------------------------------------------------

Posted: Tue Feb 08, 2005 9:12 am
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?

Posted: Wed Feb 09, 2005 12:06 am
by wacko
maybe some basic information atleast?
what is and/or what is the difference between $mg.angle and $mg.angles[1]?

Posted: Wed Feb 09, 2005 1:36 am
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...?

Posted: Wed Feb 09, 2005 2:26 am
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.

test

Posted: Wed Feb 09, 2005 4:40 am
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).