Jump to content

Help with PlaceAtMe


LtMattmoo

Recommended Posts

Not one day back on the modding scene and I've already hit a wall. I would be much obliged if anybody could help me with this problem.

 

I'm trying to use PlaceAtMe to change an object on activation. Specifically, I have a havoc-enabled bedroll misc object which, when activated, should become the static bedroll furniture. For whatever reason, although PlaceAtMe and Delete are doing their jobs, the furniture bedroll is not placed at the misc bedroll. Rather, it is placed where the misc bedroll was when initially dropped from my inventory.

 

I want to be able to drag the misc object around for positioning then have it become the furniture when I'm happy with its location.

 

I have already tried GetPosition and SetPosition but these functions make no difference. It seems as though the game does not update the position of the misc object when it is dragged to a new position.

 

 

I am hoping that someone here could reveal either what is causing this and how to get around it or an entirely different method of achieving my aims.

 

Thank-you much in advance.

Link to comment
Share on other sites

I have managed to accomplish what you are trying to do a few times in the past. I'm not 100% clear on the sequence of events you are describing above, but what I did was this:

 

The inventory object gets dropped. In a while statement it keeps checking to see if the Z-axis position has stopped changing, and if it has, it disables itself, creates the activator version at itself and then deletes itself. In my case, the activator could still be moved around via 'grabbing', or clicked on to bring up a menu. It seems like that would do the trick for your bedroll, too.

 

If that doesn't help you I'll actually dig up the scripts and share exactly what I did.

Link to comment
Share on other sites

Thanks for the reply, LittleBaron. Although, I'm not sure it helps.

 

See, if the activateable bedroll was always draggable, the player would accidentally kick it around when they walked near it.

 

However, I would still like to see those scripts as it seems to me that your inventory object is creating the activator after falling to the ground, which mine does not. For clarification, when my "activator" object is created, it loads in the position that my "inventory" object was in before falling to the ground, no matter where the inventory item is at the point of creation.

Link to comment
Share on other sites

I think the waiting period to allow the object to settle to the ground might be the key to that problem,, as otherwise I am doing the same thing you have said you are doing. This script is part of a script on the 'inventory' version of a trap from my Dwemer Trap mod.

 

 


Float PosZ
Int InTheGame

Event OnGrab()

   UnregisterForUpdate()
   InTheGame = 0

EndEvent


Event OnRelease()

   PosZ =  self.GetPositionZ()
   RegisterForSingleUpdate(0.5)
   InTheGame = 1

EndEvent


Event OnContainerChanged(ObjectReference NewC, ObjectReference OldC)

if OldC && !NewC
   PosZ =  self.GetPositionZ()
   RegisterForSingleUpdate(0.5)
   InTheGame = 1
endif

EndEvent

Event OnUpdate()

if InTheGame == 0
   return; b/c it shouldn't have been updating... but sometimes it does anyway.
endif

if !(PosZ == self.GetPositionZ())
  PosZ =  self.GetPositionZ()
  RegisterforSingleUpdate(1.0)
  return;
endif

if (PosZ == self.GetPositionZ()); we've been in the same position Z for at least 0.5 seconds... we have 'settled'
   self.DisableNoWait()
   self.PlaceAtMe(ActiveSelf,1,TRUE)
   self.Delete()
endif

EndEvent

Activator Property ActiveSelf  Auto

 

 

It also occurs to me that for similar Inventory Place At Me situations I have actually placed the activator object at the PLAYER rather than the inventory object... I think those were situations where I did not want the object to fall to the ground first.

Link to comment
Share on other sites

Well I got the time to play about with the console and found out why this is happening. As suspected, the world co-ordinates of my misc object are not updating when it is moved, either by gravity or dragging. Getting the positions of each axis always returns the same values; the position that the object was in immediately after being dropped. This, no matter how much the object is moved or how long (game and real time) a "waiting period" it is given. PlaceAtMe is working just fine, it's just being fed the wrong co-ordinates.

 

Please, if anyone can tell me why the co-ordinates might not be updating when the object is moved, a way to force the co-ordinates to update, or an alternative method to PlaceAtMe, I would be so very grateful. The entire mod (considerably big scope) rests on the functionality of this one script.

Link to comment
Share on other sites

Well I got the time to play about with the console and found out why this is happening. As suspected, the world co-ordinates of my misc object are not updating when it is moved, either by gravity or dragging. Getting the positions of each axis always returns the same values; the position that the object was in immediately after being dropped. This, no matter how much the object is moved or how long (game and real time) a "waiting period" it is given. PlaceAtMe is working just fine, it's just being fed the wrong co-ordinates.

 

Please, if anyone can tell me why the co-ordinates might not be updating when the object is moved, a way to force the co-ordinates to update, or an alternative method to PlaceAtMe, I would be so very grateful. The entire mod (considerably big scope) rests on the functionality of this one script.

 

Why do you suppose I don't experience the same issue?

Link to comment
Share on other sites

I do not experience the issue you are having, although I recall experiencing it while I was working out how to get it to work. I can currently drop the inventory objects, move them while they are still inventory objects if I grab them in time, and the activator will appear as expected where the inventory object was moved to once it is released. Nobody using the trap mod has reported the issue you are having, either. So something you are doing is different, of course.

 

Using your system though, perhaps you could just try disabling and then immediately enabling your inventory object just before it tries to create your activator, and see if that will reset its location in the game world. Also, will placing the activator object at the player instead not work for you?

Link to comment
Share on other sites

Enable-disabling won't work - I've already tried that. Additionally, my mod used to place the activator at the player, so I know I can get that to work, but that doesn't achieve the result that I'm after. I want the player to be able to handle the object's position themselves, rather than having to stand roughly where they want it to be. The most immersive and least tedious method I can think of is to have the object be able to enter a state in which it can be dragged.

 

Any more information you can give me on your experiences with this issue would be very helpful. I think, tomorrow - when I'm awake again, I shall try simply building the mod back up from scratch. Sometimes starting over can overcome such unreasonable problems.

 

Oh, and many thanks for your help so far.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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