Swimming and player.getpos z

Post » Mon Jul 09, 2012 6:41 pm

Is there any reason why player.getpos z returns the wrong z position when the player character is swimming? It seems it's magically making the character appear about 100 units higher than it should.

The following will make the player character float above the water when swimming:

set zplayer to player.GetPos zplayer.SetPos Z zplayer

Thanks.
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm

Post » Tue Jul 10, 2012 3:14 am

Yes. The engine behaves differently when the PC is swimming, including the return value of GetPos.

On ground, the z position is at the feet level (where the PC stands). When swimming, the Z position retuned by GetPos seems to switch to something around shoulder level, but SetPos is not adjusted the same way, so it will have the effect you mention.

If you walk slowly into the water, the Z position drops accordingly until the PC starts swimming. At this point the Z instantly goes from about -100 to -5.

The actual difference is 105.29

Using your example, this code would compensate that effect

if playerref.isswimming	set zplayer to playerref.GetPos z -105.29else	set zplayer to playerref.GetPos zendifplayerref.SetPos Z zplayer
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am


Return to IV - Oblivion

cron