playMaker

Author Topic: Set Property Object Types  (Read 9781 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Set Property Object Types
« on: June 20, 2012, 08:55:20 PM »
Hi,

I am trying to use Set Property on another game objects component.  I understand that I have to specify each objectType (transform, mesh, rigidbody, etc.) of the property I want to set, and I know the component property I am trying to set is a Transform.  Here's what I did:

-In my first State I used Find Game Object to locate the object I needed, and stored it in a regular GameObject variable. 
-Then I created a second variable that was of object type UnityEngine.Transform, and I used Set Object Value to store my GameObject in that as a Transform. 
-Finally I used Set Property to assign my object Transform variable to the component property.

Now, the object Transform variables say that they contain the correct gameObject, however when it comes to Set Property, the target component property doesn't seem to take the object at all.  No errors are reported, the component property just doesn't change. 
If I just forgo the first two steps and only create a state with the Set Property action in it, and directly drag the objects to be assigned into the Set Property 'Object' slot (in the action), it works okay.  (I didn't want to leave it like this though because my actions lose their variable connections whenever the object is loaded into another scene).

My guess is that the component script property I am trying to set doesn't see my Object as the type it wants (in this case, a Transform). Is there some further conversion I need to tell Unity that I am assigning a Transform?  What steps did I miss? 

Thanks for your patience and assistance in always helping me out with these problems I run into.  Cheers!


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Property Object Types
« Reply #1 on: June 21, 2012, 01:38:52 AM »
Hi,

You can't use "set Object Value" to inject the gameObject in the set property the target object. I see what you are trying to achieve, but I don't see a way currently in playmaker

maybe this is bug actually, I will talk to Alex about this to bring it to his attention.

But:

 What would be the goal of storing the transform? all properties of a transform have their related actions available that work with a gameObject reference.

What do you want to do with this transform once you have stored?

 bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Set Property Object Types
« Reply #2 on: June 21, 2012, 06:52:53 PM »
Thank you for your reply.

Quote
What would be the goal of storing the transform? all properties of a transform have their related actions available that work with a gameObject reference.

I might have misunderstood something when what I was originally trying to do didn't work.  It might be a bug, as I've found at least one in PlayMaker before after stumbling onto it out of my own ignorance.  To answer your first question though: I originally tried to use only Find Game Object, and Set Property.
The first problem I ran into was the the component I am trying to set a property on would not accept the Game Object, and since the component script was specifying a Transform, I thought I needed to retrieve just the Transform.  That's probably where I misunderstood.

Quote
What do you want to do with this transform once you have stored?

I have a camera script with a Target property, and I'm just using this Transform to set that property.  Here is what I'm trying to do in brief:

My Player can enter a Ragdoll state when hit.  For several reasons I don't need to go into, I need my camera to focus on the parent "Player" object during play, but switch focus to the root-bone of the Ragdoll when that state is in effect.

Here is the camera script Target property that will target either Player or root-bone:


Here are the Player and root-bone GameObjects to be targetted:


Here is the action used to set the property when the state changes from player-controlled to ragdoll.


... and then it gets set back when the player regains control.  Can you offer any advice?

This is all moot when I am not using PlayMaker, as I can just drag any Game Object I specify onto the component script in question, and it works perfectly.  I am using PlayMaker so I can swap the object I need via FSM.




artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Set Property Object Types
« Reply #3 on: June 26, 2012, 12:30:13 AM »
Just wanted to bump this and see if there was any thing else someone could recommend.

Is this something hutong is investigating? 

Am I approaching this from such an ignorant way that it's not worth replying to?

I appreciate any further help in setting me in the right direction. 

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Set Property Object Types
« Reply #4 on: June 26, 2012, 09:57:39 AM »
I'm looking into this now...

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Set Property Object Types
« Reply #5 on: June 28, 2012, 02:22:30 PM »
Anything new on this?


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Set Property Object Types
« Reply #6 on: June 28, 2012, 07:27:30 PM »
Get/Set Property should be a little more flexible, so you could get the Transform property from a GameObject variable. I'll take a look at this...

In the meantime, you can use the attached action: GetTransform, which gets a GameObject's Transform and stores it in an Object variable. So you would use Find Game Object, Get Transform, then Set Property on your script.

Let me know if this works for you...
« Last Edit: July 01, 2012, 09:00:59 PM by Alex Chouls »

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Set Property Object Types
« Reply #7 on: July 02, 2012, 03:23:54 PM »
Apologies for the delay in replying.  This works just perfectly, thank you for providing an action for it.

I'd like to ask if I'm using the Set Property action wrong, or if it was never intended to be used this way?

Thanks for all the fish!