playMaker

Author Topic: Object.Value as Class "Cannot convert type..."  (Read 2178 times)

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Object.Value as Class "Cannot convert type..."
« on: January 31, 2019, 06:57:07 PM »
I used another action as an example to convert an FsmObject to another class found in a different asset. In play sound we have

Code: [Select]
var audioClip = clip.Value as AudioClip;
but in my script I get an error saying "Cannot convert type 'UnityEngine.Object'..."

What are other ways of getting the FsmObject to convert type when getting this error?

Thank you
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Object.Value as Class "Cannot convert type..."
« Reply #1 on: February 01, 2019, 04:28:15 AM »
Hi,

can you show the script in question that gives the error?

Bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Object.Value as Class "Cannot convert type..."
« Reply #2 on: February 01, 2019, 08:54:37 AM »
Heres the line in my script:

Code: [Select]
public SteamVR_Action_Vector2 vector2Action;
[ObjectType(typeof(SteamVR_Action_Vector2))]
public FsmObject vector2Action;
public override void OnUpdate()
{
var vector2 = vector2Action.Value as SteamVR_Action_Vector2;
}

And attached is the script it's trying to connect to.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Object.Value as Class "Cannot convert type..."
« Reply #3 on: February 01, 2019, 11:41:33 AM »
I've also created some custom actions for SteamVR 2.2 and are running into the same problem :P

The SteamVR_Input_Actions are no longer "scriptable" as before, so i'm just using a string as input for now.

public FsmString vector2Action;

var action = SteamVR_Input.GetAction<SteamVR_Action_Vector2>(vector2Action.Value);

I'ts not ideal, but it works for now.
« Last Edit: February 01, 2019, 11:51:26 AM by LordHorusNL »

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Object.Value as Class "Cannot convert type..."
« Reply #4 on: February 01, 2019, 01:10:46 PM »
Hey Dennis!

I am using an alternate method for the toolkit as well but like you said, its not ideal. I'm hoping playmaker team may know of another method that can bypass this for the actions.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Object.Value as Class "Cannot convert type..."
« Reply #5 on: February 02, 2019, 10:40:36 PM »
Any ideas Jeanfabre?

Thanks
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Object.Value as Class "Cannot convert type..."
« Reply #6 on: February 04, 2019, 03:28:41 AM »
Hi,

 Well, If the new api doesn't objects but simple classes, then yes, you won't be able to store these reference in a an FsmObject.

for this, you'll need to use soft referencing by keeping a static dictionnary of string acting as keys and the SteamVR_Action_Vector2 class or other classes.

 in your actions, you'll use the string key to store and use that SteamVR_Action_Vector2 class. That's how I handle such case, for example when dealing with xml nodes.

 Bye,

 Jean

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Object.Value as Class "Cannot convert type..."
« Reply #7 on: February 04, 2019, 08:59:36 AM »
Gotcha thanks Jean and thanks for your input as well Dennis!
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Object.Value as Class "Cannot convert type..."
« Reply #8 on: February 04, 2019, 10:13:19 AM »
Not that i was much help but you're welcome :P

Good to see we finally have a proper solution to this.

Well i guess i'm gonna have to do some research into soft referencing then ;D
« Last Edit: February 04, 2019, 10:21:05 AM by LordHorusNL »