playMaker

Author Topic: Need a little help with Get/ Set Property Action. [SOLVED]  (Read 2670 times)

devotid

  • Playmaker Newbie
  • *
  • Posts: 45
Need a little help with Get/ Set Property Action. [SOLVED]
« on: November 28, 2013, 10:48:51 PM »
I have been using the "Get"/ "Set" Property action for a while now but i have come across a hiccup.

I cannot reach any properties of a script that i am using. Its for a car simulator in unity.  The car Axles.cs script has an option of serializing the "car setup" and i cannot figure out how to get to the Anti roll bar rate and a couple other properties.

Here is the script.
Code: [Select]

using UnityEngine;

public enum WheelPos {FRONT_LEFT, FRONT_RIGHT, REAR_LEFT, REAR_RIGHT};
[RequireComponent (typeof (Rigidbody))]
[ExecuteInEditMode()]
public class Axles : MonoBehaviour {
// [HideInInspector]
// public Wheel[] frontWheels =new Wheel[2];
// [HideInInspector]
// public Wheel[] rearWheels =new Wheel[2];
[HideInInspector]
public Wheel[] otherWheels=new Wheel[0];
[HideInInspector]
public Wheel[] allWheels;

public Axle frontAxle=new Axle();
public Axle rearAxle=new Axle();

public Axle[] otherAxles=new Axle[0];

/* void OnEnable() {
CheckWheels();
}
 */
void CheckWheels(){
if (frontAxle.leftWheel==null) Debug.LogWarning("UnityCar: front left wheel not assigned " + " (" +transform.name+ ")");
if (frontAxle.rightWheel==null) Debug.LogWarning("UnityCar: front right wheel not assigned " + " (" +transform.name+ ")");
if (rearAxle.leftWheel==null) Debug.LogWarning("UnityCar: rear left wheel not assigned " + " (" +transform.name+ ")");
if (rearAxle.rightWheel==null) Debug.LogWarning("UnityCar: rear right wheel not assigned " + " (" +transform.name+ ")");
}

void Start(){
CheckWheels();
}

void Awake(){
SetWheels();
}

public void SetWheels(){
if (frontAxle.leftWheel) frontAxle.leftWheel.wheelPos=WheelPos.FRONT_LEFT;
if (frontAxle.rightWheel) frontAxle.rightWheel.wheelPos=WheelPos.FRONT_RIGHT;
if (rearAxle.leftWheel) rearAxle.leftWheel.wheelPos=WheelPos.REAR_LEFT;
if (rearAxle.rightWheel) rearAxle.rightWheel.wheelPos=WheelPos.REAR_RIGHT;

frontAxle.wheels =new Wheel[0];
if (frontAxle.leftWheel!=null && frontAxle.rightWheel!=null) {
frontAxle.wheels =new Wheel[2];
frontAxle.wheels[0]=frontAxle.leftWheel;
frontAxle.wheels[1]=frontAxle.rightWheel;
}
else if (frontAxle.leftWheel!=null || frontAxle.rightWheel!=null){
frontAxle.wheels =new Wheel[1];
if (frontAxle.leftWheel!=null) frontAxle.wheels[0]=frontAxle.leftWheel;
else frontAxle.wheels[0]=frontAxle.rightWheel;
}
frontAxle.camber=Mathf.Clamp(frontAxle.camber,-10,10);

rearAxle.wheels =new Wheel[0];
if (rearAxle.leftWheel!=null && rearAxle.rightWheel!=null) {
rearAxle.wheels =new Wheel[2];
rearAxle.wheels[0]=rearAxle.leftWheel;
rearAxle.wheels[1]=rearAxle.rightWheel;
}
else if (rearAxle.leftWheel!=null || rearAxle.rightWheel!=null) {
rearAxle.wheels =new Wheel[1];
if (rearAxle.leftWheel!=null) rearAxle.wheels[0]=rearAxle.leftWheel;
else rearAxle.wheels[0]=rearAxle.rightWheel;
}
rearAxle.camber=Mathf.Clamp(rearAxle.camber,-10,10);

Wheel[] m_otherWheels=new Wheel[otherAxles.Length*2];
int i=0;
foreach(Axle axle in otherAxles){
if (axle.leftWheel!=null && axle.rightWheel!=null) {
axle.wheels =new Wheel[2];
axle.wheels[0]=m_otherWheels[i]=axle.leftWheel;
axle.wheels[1]=m_otherWheels[i+1]=axle.rightWheel;
i+=2;
}
else{
axle.wheels =new Wheel[1];
if (axle.leftWheel!=null) axle.wheels[0]=m_otherWheels[0]=axle.leftWheel;
else axle.wheels[0]=m_otherWheels[0]=axle.rightWheel;
i+=1;
}
axle.camber=Mathf.Clamp(axle.camber,-10,10);
}

otherWheels=new Wheel[i];
m_otherWheels.CopyTo(otherWheels, 0);

allWheels = new Wheel[frontAxle.wheels.Length + rearAxle.wheels.Length + otherWheels.Length];

frontAxle.wheels.CopyTo(allWheels, 0);
rearAxle.wheels.CopyTo(allWheels, frontAxle.wheels.Length);
if (otherWheels.Length!=0) otherWheels.CopyTo(allWheels,frontAxle.wheels.Length + rearAxle.wheels.Length);
}
}

[System.Serializable]
public class Axle
{
public Wheel leftWheel;
public Wheel rightWheel;
[HideInInspector]
public Wheel[] wheels;
public bool powered;
public float suspensionTravel=0.2f;
public float suspensionRate=20000;
public float bumpRate=4000;
public float reboundRate=4000;
public float fastBumpFactor=0.3f;
public float fastReboundFactor=0.3f;
public float antiRollBarRate=10000;
public float brakeFrictionTorque=1500;
public float handbrakeFrictionTorque=0;
public float maxSteeringAngle=0;
public float forwardGripFactor=1;
public float sidewaysGripFactor=1;
public float camber=0;
public float caster=0;
[HideInInspector]
public float deltaCamber;
[HideInInspector]
public float oldCamber;
public CarDynamics.Tires tires;
public float tiresPressure=200;
public float optimalTiresPressure=200;
}

When i drag the Axles.cs script to the FSM menu it only shows......

enabled
Hideflags
name
UseGuiLayout



Any idea on how to edit the script to access the variables on the bottom?

Thanks
Kevin
« Last Edit: February 13, 2014, 08:45:21 PM by devotid »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need a little help with Get/ Set Property Action.
« Reply #1 on: November 29, 2013, 06:36:28 AM »
Hi,

 It's because Get/Set Property only access the simple public types, but I am still unsure personally if this is by design of a glitch. I will enquire.

 Bye,

 Jean

devotid

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Need a little help with Get/ Set Property Action.
« Reply #2 on: November 29, 2013, 01:25:09 PM »
Thank you very much Jean.  If anybody can fix this.... its you.  :)

I am also talking with the creator of the Unity Car script and he is looking into this as well...... i am thinking of rewriting the entire set up manager if i cannot access these variables.

I tried moving the variables to the top of the page so i can see them.... but the script doesnt "declare them" until the script is running.  I think it sets the front and rear axles "after" the script is running so there is actually a front and rear set of variables.

I can see the variables in the editor view of Unity but cannot access them via an FSM.

In an older version of unitycar i could access them fine..... but since he has added this new axle script that "manages" the axles it is not possible anymore.

Thanks again.

Kevin

Roger Lee

  • Playmaker Newbie
  • *
  • Posts: 31
Re: Need a little help with Get/ Set Property Action. [SOLVED]
« Reply #3 on: March 15, 2014, 10:29:32 PM »
I'm having the same problem with the FPSPlayer script from the Realistic FPS Prefab product.  I can access all the other scripts fine, but this single one fails to load any properties when added to a state.  It actually throws up bunch of "failed to load" entries into the debug console.

Without being able to access this script I can't set player hit points for custom made dangers in my environment.

Damn, I should learn how to code!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need a little help with Get/ Set Property Action. [SOLVED]
« Reply #4 on: March 18, 2014, 09:10:25 AM »
Hi,

 can you paste the exacty errors? you mae need to wait for UFPS to initialize or something.

bye,

 Jean