playMaker

Author Topic: Game Object Compare Doesn't work as expected  (Read 482 times)

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
Game Object Compare Doesn't work as expected
« on: August 17, 2022, 07:15:53 AM »
Hello All,

Okay, I am not able to figure out something as basic as Game Object Compare action.

PLEASE REFER TO IMAGE ATTACHED

Context:
A 3d point and click game, when we click on a hotspot the camera tweens to that location. I call this location NODE(prefab).

I have a Global Variable 'Current_Node' of type 'gameObject' (Node) to keep track of Player location. Right now it updates just fine as I move the Player from node to node as I click on them. I can actually see it updating whenever I hop from one Node to another.


Goal:
I need to activate a collider on a white button on the 'Node:Hawk'

Problem:
'Game Object Compare' doesn't seem to work the way I expect.
May be I am missing something very basic here or may be I am using it wrong.

On the 'SwitchGeo' fsm I am using this action on state1. I am trying to compare the 'current node' with the 'Node:Hawk'. Both these are of gameobject type.

When I arrive at Node:Hawk, the global 'Current_Node' corresponds to it.

Although, inside 'Game Object Compare action,  the bool 'isCurrent' never flips to true and the event 'activateButtonCollider' doesn't fire.

I have tried 'Game Object Compare' in other situations and managed to NEVER get it to work. :-\

Please Help, may be I am using it in a wrong way?





« Last Edit: August 17, 2022, 07:18:07 AM by GMPlay »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Game Object Compare Doesn't work as expected
« Reply #1 on: August 23, 2022, 06:05:05 AM »
Hi.
As far as i know, when i used it.
It was working for me.

Just make sure that it compares with the exact same object (so not an instance/copy/spawned prefab)

Each object has an unique Guid as a reference, so each prefab spawned in a scene will have a different Guid therefor a it will not be compared as the same.

GMPlay

  • Playmaker Newbie
  • *
  • Posts: 28
Re: Game Object Compare Doesn't work as expected
« Reply #2 on: August 23, 2022, 07:58:10 AM »
That is a cool tip!

So I found a way around this by comparing the names instead of the actual game object.

I realized that comparing game objects isn't ideal in many cases, for the reason you have mentioned.

Thanks!!