Jump to content

SetPos freezes my character


darkneon

Recommended Posts

I'm working on a 'device' for short-range teleportation. the teleportation it self works fine (Tested it) but after translocating my self, i'm unable to move, unless i fast travel

 

the device is a modded multi-plas rifle, firing a single plasma projectile.

the projectile is affected by gravity to make it's range limited.

upon impact the projectile explodes (again, no damage) and spawns a tiny, coded radroach.

 

this is the code i'm currently using for the radroach:

scn aaTeleportSCPT

ref roachref
float teleX
float teleY
float teleZ

begin gamemode
set roachref to GetSelf
set teleX to roachref.GetPos X
set teleY to roachref.GetPos Y
set teleZ to roachref.GetPos Z
Player.SetPos X teleX
Player.SetPos Y teleY
Player.SetPos Z teleZ
roachref.Disable
end

Link to comment
Share on other sites

The problem is the last line.

 

'Disable' - that just stops the graphics from rendering. Your script is still running in gamemode every frame, hence why you can't seem to move.

 

Follow that line with 'MarkForDelete'

 

BTW, You don't need to use the 'roachref.' reference prefix. The current object instance is implied.

 

When you have gamemode blocks that you only want to happen once, use a variable to protect the block.

You can't be sure that the object will actually be deleted in the same frame.

I'm not sure if the markForDelete flag is checked before running the block again, so it's a good idea to use a protection block here too.

 

ref roachref
float teleX
float teleY
float teleZ
int iDone

begin gamemode
   if iDone == 0
       set iDone to 1
       set roachref to GetSelf 
       set teleX to GetPos X 
       set teleY to GetPos Y 
       set teleZ to GetPos Z 
       Player.SetPos X teleX 
       Player.SetPos Y teleY 
       Player.SetPos Z teleZ 
       Disable
       MarkForDelete
   endif
end

Link to comment
Share on other sites

As a side note - getself always returns 0 on a spawned actor, so roachref was zero - but roachref isn't needed anyway as tunaisafish pointed out.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...