Quantcast
Channel: Questions in topic: "temporary"
Viewing all articles
Browse latest Browse all 97

Add a temporary variable to an array

$
0
0
So I'm trying to add a temporary variable inside a function to an array. This variable is of a custom made class. Unfortunately I can't seem to get it to work. The array increases size but when I "call" for the variable it always comes out emtpy unless I declare it outside the function.. Here is the current code where I add the variable: var pickUpAction : PlayerActions; function PickUp (selectedObject : Transform){ GoTo(selectedObject); //Add a pickUpAction // var pickUpAction : PlayerAction; //this is where I wanted to have the variable so it disappears after being added. pickUpAction.interaction = PickUpAction; pickUpAction.selectedObject = selectedObject; globalActions.Add(pickUpAction); } And here is the example of a function that later on uses it: function DoAction (){ currentAction = (globalActions[0] as PlayerAction); currentAction.interaction (); globalActions.RemoveAt(0); } and this is the class of the variable: class PlayerAction { var interaction : function():void; var selectedObject : Transform; var selectedDestination : Transform; var selectedPosition : Vector3; }; I'm quite new to programming so sorry if I'm missing the obvious! Any help very appreciated.

Viewing all articles
Browse latest Browse all 97

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>