Rotating placeAtMe objects

Post » Fri May 04, 2012 8:44 am

hi again
i've encountered a small problem here, i got a object that i spawn using a place at me command via script
the problem is the object is facing the wrong way
is there a way to rotate it or is it not possible?
i tried the object.rotate x 180 but its not working
anyone what to see whats wrong with my code?

edit: i'm using setangle now instead but however it will only face one direction and that is south..
i'm trying to get it to face where my player is facing
since default its facing behind me i'm using 360 - the player direction to make it face the right way
correct me if i'm wrong
any help will be appreciated :)
thanks

scn StaticForceFieldModuleScriptShort ButtonShort MenuRef placedObjectfloat playerDirectionBegin OnActivate playerShowMessage StaticForceFieldModuleMessageSet playerDirection to (360-Player.GetAngle Z)Set Menu To 1EndBegin ScriptEffectStartIf Menu == 1  Set Button To getButtonPressed   If Button == 0   set placedObject to Player.PlaceAtMe StaticForceFieldGenerator 1   placedObject.setangle Z playerDirection   ElseIf Button == 1   ElseIf Button == 2    Activate   endIfelse  set placedObject to Player.PlaceAtMe StaticForceFieldGenerator 1  placedObject.setangle Z playerDirectionendIfEnd


the menu part is for when the item is not in player inventory
if allows player to activate the force field from within the world
the else part runs if the ingestible is used from inventory
both spawn a force field but i just won't rotate
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am

Post » Fri May 04, 2012 7:52 am

360 would rotate it completely around to the way it started. Try...

Set playerDirection to Player.GetAngleZ
Set playerDirection to playerdirection - 180
placedObject .setangle Z playerDirection


Also I believe that placeatme can be inconsistent with its placement of objects so you might want to refine it a
little. The following should place an object in front of the player 100 units away (or whatever you want for the
npcy variable.

set npcy to 100
set pz to player.GetPos Z
set px to player.GetPos X
set py to player.GetPos Y
set angz2 to player.getangel z

set posX to (player.getpos x + npcX * cos angz2 + npcY * sin angz2)
set posY to (player.getpos y - npcX * sin angz2 + npcY * cos angz2)
set angz2 to angz2 - 180

set placedObject to Player.PlaceAtMe StaticForceFieldGenerator 1

placedObject.setangle Z angz2
placedobject.setpos x px
placedobject.setpos y py
placedobject.setpos z pz


To make sure collision works (if you have problems) I place my object, then disable it and move it to a marker in a holding cell.
Then in the next frame I move it to the player, do all the position stuff, and enable it. So if you have colission issues try that.


Just pulled this from one of my scripts so hope it works for you. These position variables are floats btw.
User avatar
Mélida Brunet
 
Posts: 3440
Joined: Thu Mar 29, 2007 2:45 am

Post » Fri May 04, 2012 7:33 am

sorry to sound dumb but i get everything up to the trigonometry part
what is npcX?
edit: it turns out npcX can just be not initialized 0?

everything is working fine now the force field spawns 100 units in front
thanks for your help :smile:

one slight problem is if i look down or up it will spawn facing weirdly
no biggy i guess i'll have to look straight whenever i spawn it


scn StaticForceFieldModuleScriptShort ButtonShort MenuRef placedObjectfloat spawnYfloat spawnXfloat posXfloat posYfloat posZfloat angleBegin OnActivate playerShowMessage StaticForceFieldModuleMessageSet Menu To 1EndBegin ScriptEffectStartIf Menu == 1  Set Button To getButtonPressed   If Button == 0   set spawnY to 100   set posX to player.GetPos X   set posY to player.GetPos Y   set posZ to player.GetPos Z   set angle to player.getangle z   set posX to (player.getpos x +  spawnX * cos angle + spawnY * sin angle)   set posY to (player.getpos y -  spawnX * sin angle+ spawnY * cos angle)   set angle to angle - 180   set placedObject to  Player.PlaceAtMe StaticForceFieldGenerator 1   placedObject.setangle Z angle   placedobject.setpos X posX   placedobject.setpos Y posY   placedobject.setpos Z posZ   ElseIf Button == 1   ElseIf Button == 2	Activate   endIfelse   set spawnY to 100   set posX to player.GetPos X   set posY to player.GetPos Y   set posZ to player.GetPos Z   set angle to player.getangle z   set posX to (player.getpos x +  spawnX * cos angle + spawnY * sin angle)   set posY to (player.getpos y -  spawnX * sin angle+ spawnY * cos angle)   set angle to angle - 180   set placedObject to  Player.PlaceAtMe StaticForceFieldGenerator 1   placedObject.setangle Z angle   placedobject.setpos X posX   placedobject.setpos Y posY   placedobject.setpos Z posZendIfEnd
User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am

Post » Fri May 04, 2012 1:25 am

Not sure why it changes depending on where you look, it shouldn't. I noticed a small error, maybe that has something to do with it..

posY to (player.getpos y - spawnX * sin angle+ spawnY * cos angle)


Should be a space between angle and + (maybe you fixed that)

Also try putting
placedObject.setangle Z angle

after the xyz stuff like this...

placedobject.setpos X posX
placedobject.setpos Y posY
placedobject.setpos Z posZ
placedObject.setangle Z angle

Don't know, may help.
User avatar
Chantelle Walker
 
Posts: 3385
Joined: Mon Oct 16, 2006 5:56 am

Post » Fri May 04, 2012 12:53 am

it didnt change anything but this is good enough, i jus have to look in the direction i want it to spawn..i wont spawn it look at the floor or sky in the first place so its algud
thanks for your help again :)
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Thu May 03, 2012 11:58 pm

Well I think I have a solution for you anyway. Instead of calling player.placeatme, create a dummy cell with an xmarker in it, and call XmarkerRef.placeatme. Then you can disable it, move it to the player, set its position, and enable. This way the players looking direction never gets involved like it can with placeatme. I just used this for replacing toilets with ones you can sit on and it worked.
User avatar
Chris Johnston
 
Posts: 3392
Joined: Fri Jul 07, 2006 12:40 pm

Post » Fri May 04, 2012 6:09 am

the thing is by using set position it means the direction is always fixed
eg the force field will be facing north and will only make sense if the player is facing north

eg2
____________________
_____me> ___________________________

if i were to do set position without involving player direction the force field won't shield me from the mutant

______F_____________
_____me> ___________________________

but if i were to involve player direction i will guarantee protection from mutant

____________________
_____me> F__________________________


correct me if i am mistaken on how the set position works
User avatar
Laura Tempel
 
Posts: 3484
Joined: Wed Oct 04, 2006 4:53 pm

Post » Fri May 04, 2012 6:27 am

The problem isn't with setangle, it starts with the player.placeatme. player.Placeatme objects orient to the way the player is looking up or down (some don't seem to be affected like some sit markers and one of the sleeping mats used in one of my mods). So calling Xmarker.placeatme makes sure that it isn't affected by skewed x and y angles like when called on the player. Just try it if you have time, can't hurt.

Edit: I'm not saying don't use setangle z, you still need to set it to the players z angle...

set placedObject to XmarkerRef.PlaceAtMe StaticForceFieldGenerator 1
placed object.disable
placedobject.moveto player ;this should not affect its x/y angles
placedObject.setangle Z angle
placedobject.setpos X posX
placedobject.setpos Y posY
placedobject.setpos Z posZ
placedobject.enable
User avatar
Marcin Tomkow
 
Posts: 3399
Joined: Sun Aug 05, 2007 12:31 pm


Return to Fallout 3