Accessible inventory of previous player object (switching to new player object)

I just wanted to share a funny work around that I figured out by accident.

So my project hinges on the player becoming a robot and leaving their body behind, but I needed any possible objects that the player was already carrying to be accessible by the next player object. At first, I thought I would need to create an array for the player's inventory and drop each item one by one, but then I realized that you can just do this instead:

Turn first player object into "Object/room" go to container tab, check "can be opened" box, then create a script that opens the player object when the player switches to the next player object. This worked like a charm!


create a script that opens the player object when the player switches to the next player object

This sounds like a pretty neat way of doing it

Although:

Turn first player object into "Object/room" go to container tab, check "can be opened" box,

Not sure why this bit is necessary


I am guessing your code requires the player to pick back up all the items, what if you can just add all to inventory instead:

  1. you should change "bot" in this script to whatever your robot is called. You need to create an object called temp and make temp invisible. Inside the "transform robot" button, add in this script.
foreach (item, ScopeInventory()) {
  item.parent = temp
}
ChangePOV (bot)
foreach (item, GetDirectChildren(temp)) {
  item.parent = game.pov
}

I am guessing your code requires the player to pick back up all the items, what if you can just add all to inventory instead:

I would have suggested something like this; although running the loop twice seems unnecessary. Why not:

items = ScopeInventory()
ChangePOV (new_player)
foreach (item, items) {
  item.parent = new_player
}

You could even put this into the game.changedpov script if you really want to:

foreach (item, GetDirectChildren (oldvalue)) {
  item.parent = game.pov
}
InitPOV (oldvalue, game.pov)

But when I made a game with changing player objects, I found that it seemed more natural for the player to be able to take items from (and give items to) the previous player object as if they were a container.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums