Forum rules - please read before posting.

I want to set a global variable, call it CurrentObject, to object being looked at in a FPS.

In the hotspot prefab I want to set a global variable with either an object reference or object name of the current object being looked at. I think it has to be an object name because I don't see GameObject in the global variable "Type" field. This will allow other scripts/actions to access the fields of the current object. In general, I don't see a way to reference the object running an action.

Does anyone have any suggestions on how to accomplish this? I've tried a few approaches but with no luck. I must be missing something obvious. 

Comments

  • Welcome to the community, @spcmicro.

    You can use parameters for this, rather than variables.  Parameters are a way of changing an ActionList's fields dynamically when run - see this tutorial.

    If your Hotspot's Interaction contains a GameObject parameter, you can have the Hotspot pass itself to it when run.  You can then use that parameter in your Actions whenever a GameObject is required.
  • Thank you for the response. It wasn't clear how to access the current object but I get it now.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.