A bit to do with another thread, where Im trying to get my character to hold stuff.
I need the method to do tis, but also some suggestions of the "methododgy" of my menu system.
In my game all items can be clicked on and are added to the inventory, SOME of them, NOT ALL you will use the normal Adventure Creator/Adventure game method. (Drag FROM the inventory TO the thing in the scene, like keys for example) but SOME things (gun and torch and axe) you should pick up (it goes to your inventory, but then when you click themin the inventory, they go to your hand.
When in your hand, pressing FIRE will.. er do them.. Torch =switch on or off Gun= fire, Axe = swing.
So then, with THOSE items, I need to be able to UN-equip them, I could have a key to do that, but thats a bit against my game interface (I want to keep things simple, without lots of different keys to remember)
To enter the Inventory at all (is 1st person game so you need to release the cursor) We hit TAB
So REALLY I need to be able to "put an item back" in the inventory, FROM your hand, I need the menu item to be a toggle button, one that STAYS selected, when you are holding it, and a second click will drop it. Of course, I also want it that if you go straight from holding the torch to holding the gun, it automatically drops the torch and takes the gun...
Is this waaay too tricky, or is there a better way to handle equipping, that isnt so far away from the Adventure game way of doing things?
Comments
Q: In the action list editor... should each action light up green as it fires? Even when its an Action List?
Cos mine isnt... is that a hint?
Perhaps a better way (and one that would also solve your "selected" item icon issue) would be to use the Inventory: Add or remove Action to swap your "unequipped" item with a separate "equipped" item with it's own icon.
Hmm.. thats interesting... never thought of that... you are a clever chap... If I remove one while adding another, will they occupy the same "slot" in the inventory...
Long time!
Im STILL working on this... ok back after doing some paid jobs.
Best ting is that I show you a flim.
First one is that although the concept of clicking an inventory item, the torch, and switching to an UNEQUIP menu item is working, the reference to the torch in the EQUIP is getting lost after first use of the torch. As is the references to the torch in the UNEQUIP action list.
I am using Set parent/Clear parent to remove the torch, but to get rid of it I have to destroy it with remove object. Maybe cos its not destroyed it can't be found?
Second LESSER issue is that the torch light, which is being turned on by the lightswitch script Message send Turn On.. is NOT turning off...
EDIT: Sorry.. Last bit incorrect... when I shot the video I forgot to add the Torchlight to the light off (message send turn off) action in the UN-EQUIP inventory item... it MIGHT work now, but who knows as I cant get the torch to work a second time to find out... it might also be losing its reference.
The video's quite blurry to make out, but you don't need to re-drag your Torch asset into your Actions if the Actions show a recorded Constant ID number - as the Actions will search for any object with this number in the scene when the game runs. But the Torch object itself needs to be in the scene when they run.
If you're removing the object from the scene, you will have to make sure you also add the object when you need it. You can use the Object: Check presence Action to determine whether-or-not the torch is in the scene, and add it in if not.
Alternatively, just unparent the torch and hide it from view, instead of deleting it.
But seems like I may be deleting it for good...when I UN Equip it... I thought putting it in the hand again on EQUIP would add it back, but now I see that it IS in game from start... just sitting and waiting at 0,0,0...
how would YOU hide it from view?
AC.KickStarter.playerInput.cursorIsLocked = true;
If you are busy, then dont worry, RE: my other thread where Im hoping to NOT HAVE to lock the cursor to interact, depends on my Player movement...
BUT.. Just to get the answer, if you are lazing around wondering what to do while the kettle boils../*
*
* Adventure Creator
* by Chris Burton, 2013-2015
*
* "ActionTemplate.cs"
*
* This is a blank action template.
*
*/
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AC
{
[System.Serializable]
public class ActionCursorLock : Action
{
// Declare variables here
public ActionCursorLock ()
{
this.isDisplayed = true;
category = ActionCategory.Custom;
title = "CursorLock";
description = "This should lock the cursor in center of the screen, fron an action list.";
}
override public float Run ()
{
/*
* This function is called when the action is performed.
*
* The float to return is the time that the game
* should wait before moving on to the next action.
* Return 0f to make the action instantenous.
*
* For actions that take longer than one frame,
* you can return "defaultPauseTime" to make the game
* re-run this function a short time later. You can
* use the isRunning boolean to check if the action is
* being run for the first time, eg:
*/
if (!isRunning)
{
isRunning = true;
return defaultPauseTime;
}
else
{
isRunning = false;
return 0f;
}
}
#if UNITY_EDITOR
override public void ShowGUI ()
{
// Action-specific Inspector GUI code here
AfterRunningOption ();
}
public override string SetLabel ()
{
// Return a string used to describe the specific action's job.
string labelAdd = "";
return labelAdd;
}
#endif
}
}
override public float Run ()
{
AC.KickStarter.playerInput.cursorIsLocked = true;
return 0f;
}