Question about TranslateTo:

Post » Tue Jun 19, 2012 10:55 pm

Are the X and Y axises relative to the player changing as the bearing (or azimuth) of the player changes? In other words is the player always facing on say a positive X? Or is it set to a 'true north' on game map grid and the PC traverses it. Maybe it's both depending on code?

I ask because I'm using a vertical translate to pop the player into the air. What I'd like it to do is also propel the character forward at an angle. That is to say always forward regardless of the characters bearing. That of course is only possible if the PC is always on the same azimuth and just changes bearing.
User avatar
Kill Bill
 
Posts: 3355
Joined: Wed Aug 30, 2006 2:22 am

Post » Wed Jun 20, 2012 6:35 am

Danger will Robinson...if you change either X or Y rotation axes, the object will NOT remain level when you rotate it on the Z axis. I tried for a long time to figure out how to tilt something up or down and remain level, and eventually gave up...there is no doubt a way to do it ,but it involves heavy duty trig skills.

Also, I've observed some strange things moving around with translates out in the world. Rubberbanding, attempting to go one direction and going in a completely different direction...I think each subcell has a totally separate XYZ axis, so moving from 1000,1000,1000 in one cell to a (relative) position of 10000,10000,1000 will probably NOT move you Northeast as you might expect, since it crosses a subcell boundary.
User avatar
ruCkii
 
Posts: 3360
Joined: Mon Mar 26, 2007 9:08 pm

Post » Wed Jun 20, 2012 3:52 am

I don't think there are separate XYZ axes per cell. I made an airship that I managed to fly from Solitude to Morthal without any problems.
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Post » Tue Jun 19, 2012 10:03 pm

Hmm, well that svcks. I was hoping I could do a Vampire Leap script by using TranslateTo. But if for example I set X and Y from a GetPosition to +500 and +500 respectively the player will always move 'westerly'. So there is a 'true north' in game. Hmm, unless I add maybe four different bearing checks. Or perhaps 8. That's a lot of code just to jump into the air in the 'relative' direction the player is facing. WTH I'll try it anyway :D
User avatar
Dorian Cozens
 
Posts: 3398
Joined: Sat May 26, 2007 9:47 am

Post » Tue Jun 19, 2012 11:41 pm

It's just a little bit of math in order to move in the direction the player is facing:

scriptname example extends activemagiceffectFloat property TargetDistance autoFloat property Speed autoEvent OnEffectStart(Actor akTarget, Actor akCaster)    float anglez = akTarget.GetAngleZ()    float anglex = akTarget.GetAngleX() * -1    float offsetz = TargetDistance * math.sin(anglex)    float tempfloat = TargetDistance * math.cos(anglex)    float offsetx = tempfloat * math.sin(anglez)    float offsety = tempfloat * math.cos(anglez)    float posx = akTarget.GetPositionX() + offsetx    float posy = akTarget.GetPositionY() + offsety    float posz = akTarget.GetPositionZ() + offsetz    akTarget.TranslateTo(posx, posy, posz, 0, 0, 0, Speed, 0)    EndEvent

EDIT: forgot about altitude
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Wed Jun 20, 2012 4:21 am

....wow.

You're the man. i'm gonna work that in to my Bat Form script so that it looks like the player leaps forward into the air and turns into a cloud of bats. Currently that already happens but instead of forward at an angle you just go straight up.


I noticed a tiny bug too with my flying script. Maybe it's related to the while loop. But if you I'm holding down the forward button while I end the spell my character just keeps flying in an uncontrollable direciton. But if I let go of the forward button and end the spell the effects all cancel and my character falls to the ground as intended. Its a small bug but for better or worse my Bat Form is working and it is fun as **** to play!

Haven't updated it yet. Will do so later this week after I get Siring and Ambushers working.
User avatar
Shaylee Shaw
 
Posts: 3457
Joined: Wed Feb 21, 2007 8:55 pm

Post » Wed Jun 20, 2012 2:47 am

I don't suppose you could write functions to handle an object's rotation on it's local Roll (Front to back axis to rotate clockwise or counterclockwise while maintaining the same facing and pitch), Pitch (Side to side axis, to angle upwards or downwards while maintaining the same left/right vector and Roll), and Yaw (Left and right turns while maintaining roll and pitch) axes, RandomNoob?
User avatar
Logan Greenwood
 
Posts: 3416
Joined: Mon Jul 30, 2007 5:41 pm

Post » Wed Jun 20, 2012 7:33 am

I don't think there are separate XYZ axes per cell. I made an airship that I managed to fly from Solitude to Morthal without any problems.

Every time I tried to move something the player was standing on, the player tries to stay put while the thing he's on is moving.
User avatar
kyle pinchen
 
Posts: 3475
Joined: Thu May 17, 2007 9:01 pm

Post » Wed Jun 20, 2012 7:47 am

Now that is complicated. Trying to use SetAngle() on the player also doesn't work. Setting the Z angle would only turn the player left to right (is that the yaw?) while setting the X angle only changes the player's view point in 1st person, with no effect on the actual body. Haven't had any reason to try with the Y angle.

Instead of trying to work all that out for my airship, I just used http://www.creationkit.com/TranslateToRef_-_ObjectReference. Using this function, the ship would try to match the angle of the target so I would not have to try and calculate like for TranslateTo.

I set the Z angle of the target equal to my ship's current Z angle + GetHeadingAngle. That way, my ship would slowly turn towards the target as it is translating through the air. Unfortunately, GetHeadingAngle is only for the angle about the Z axis, there's no such function for the other axes so I just used a default of 15 degrees whenever I was ascending/descending or turning to port/starboard.

I just wrote this function for GetHeadingAngle about the X axis, I don't know if it'll work, but you can try it:

float Function GetHeadingAngleX(ObjectReference Source, ObjectReference Target)	float sPosZ = Source.GetPositionZ()	float tPosZ = Target.GetPositionZ()	float distance = Source.GetDistance(Target)	float sAngleX = Source.GetAngleX()		float pOffsetZ = tPosZ - sPosZ	float aOffsetX = math.asin(pOffsetZ / distance)	aOffsetX *= -1		float AngleOffset = aOffsetX - sAngleX		Return AngleOffsetEndFunction

EDIT: I uploaded my http://www.mediafire.com/?l5uucyx685888a4 to mediafire if you want to take a look. I tried to use levers to control it, but they don't translate with the ship at the exact same time. I'm going to put it on hold until SKSE comes out with some way for me to use hot keys. The added spell lets you teleport to the ship and start/stop it if you're on it.
User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Wed Jun 20, 2012 7:14 am

I was wondering myself if it would be possible to 'swirl' the player up into the air like a tornado effect.

				 float anglez = Caster.GetAngleZ()				 float anglex = Caster.GetAngleX() * -1				 float offsetz = TargetDistance * math.sin(anglex)				 float tempfloat = TargetDistance * math.cos(anglex)				 float offsetx = tempfloat * math.sin(anglez)				 float offsety = tempfloat * math.cos(anglez)				 float cposx = Caster.GetPositionX() + 700				 float cposy = Caster.GetPositionY() + 700				 float cposz = Caster.GetPositionZ() + 700				 Caster.TranslateTo(cposx, cposy, cposz, 0, 0, 0, Speed, 0)

Did I do that right?

EDIT: I renamed them to cpos because my script was already using pos
User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Wed Jun 20, 2012 9:00 am

EDIT: I uploaded my http://www.mediafire.com/?l5uucyx685888a4 to mediafire if you want to take a look. I tried to use levers to control it, but they don't translate with the ship at the exact same time. I'm going to put it on hold until SKSE comes out with some way for me to use hot keys. The added spell lets you teleport to the ship and start/stop it if you're on it.

Could you make an "actor" with the lever model (Talking activator?) and use the SetVehicle() method to attach it on there?
User avatar
Josh Sabatini
 
Posts: 3445
Joined: Wed Nov 14, 2007 9:47 pm

Post » Wed Jun 20, 2012 1:38 am

I was wondering myself if it would be possible to 'swirl' the player up into the air like a tornado effect.

				 float anglez = Caster.GetAngleZ()				 float anglex = Caster.GetAngleX() * -1				 float offsetz = TargetDistance * math.sin(anglex)				 float tempfloat = TargetDistance * math.cos(anglex)				 float offsetx = tempfloat * math.sin(anglez)				 float offsety = tempfloat * math.cos(anglez)				 float cposx = Caster.GetPositionX() + 700				 float cposy = Caster.GetPositionY() + 700				 float cposz = Caster.GetPositionZ() + 700				 Caster.TranslateTo(cposx, cposy, cposz, 0, 0, 0, Speed, 0)

Did I do that right?

EDIT: I renamed them to cpos because my script was already using pos

I think that will only cause the player to keep drifting higher and off to the northeast. If by tornado effect, you mean you want the player to spin, you could use "Caster.TranslateTo(cposx, cposy, cposz, 0, 0, 180, Speed, 100)". That should cause the player to try to turn around, and since you're using the function in a while loop, the player should keep turning.

Could you make an "actor" with the lever model (Talking activator?) and use the SetVehicle() method to attach it on there?

I hadn't thought of that. I'll try it and post my results.

EDIT: No, it didn't work. Talking activators aren't considered actors. I tried to cast them as actors in my script, but they still wouldn't move along with the ship.
User avatar
Mrs Pooh
 
Posts: 3340
Joined: Wed Oct 24, 2007 7:30 pm


Return to V - Skyrim