playMaker

Author Topic: I'd like to share a variable.  (Read 3360 times)

choi

  • Playmaker Newbie
  • *
  • Posts: 40
I'd like to share a variable.
« on: August 09, 2012, 11:24:58 PM »
C #, JavaScript, or you can control variables do?
I'd like to share a variable.
Please help.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: I'd like to share a variable.
« Reply #1 on: August 10, 2012, 02:27:45 AM »
Hi,

 Can you precise a bit what you are after? not sure I make sense of your post.

 bye,

 Jean

choi

  • Playmaker Newbie
  • *
  • Posts: 40
Re: I'd like to share a variable.
« Reply #2 on: August 10, 2012, 04:07:55 AM »
I'm sorry.
In the following code,
the "public float power" that is stored in the value used in playmaker possible?


-------------------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;

public class ForceToBall : MonoBehaviour {
   public GameObject followCamera;
   public float power;
   
   GameManager gm;
   
   // Use this for initialization
   void Start () {
      gm = GameObject.Find ("/GameManager").GetComponent<GameManager>();
   }
   
   // Update is called once per frame
   void Update () {
      if(gm.isReady) {
         gameObject.rigidbody.isKinematic = true;
         if(Input.GetKeyDown(KeyCode.F)) {
            gameObject.rigidbody.isKinematic = false;   
            Force();   
         }
         if(Input.GetKeyDown(KeyCode.DownArrow)) {
            if(power>100.0f) {
               power += -100.0f;   
            }
         }
         if(Input.GetKeyDown(KeyCode.UpArrow)) {
            power += 100.0f;   
         }
      } else {
         gameObject.rigidbody.isKinematic = false;   
      }
   }
   
   
   void Force() {
      gm.isReady = false;
      followCamera.SendMessage("SetSwing");
      Vector2 direction = new Vector2(transform.position.x-followCamera.transform.position.x, transform.position.z - followCamera.transform.position.z);
      rigidbody.AddForce(new Vector3(direction.x*power, 5.0f*power, direction.y*power));
      //rigidbody.AddTorque(new Vector3(100.0f, 0.0f, 0.0f),ForceMode.Force);
      GameObject.Find("SoundManager/DriverSound").audio.Play();
   }
}
------------------------------------------------------------------------------------------------------------------

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: I'd like to share a variable.
« Reply #3 on: August 10, 2012, 05:42:23 AM »
Hi,

 Yes, you need to use the action "set property" or "get property" to set ang et public values in components.

bye,

 Jean

choi

  • Playmaker Newbie
  • *
  • Posts: 40
Re: I'd like to share a variable.
« Reply #4 on: August 11, 2012, 09:17:13 PM »
Thank you.
Is there work to see a sample?  :'(

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: I'd like to share a variable.
« Reply #5 on: August 11, 2012, 11:34:13 PM »
I seem to be giving out this link quite a bit. :)



choi

  • Playmaker Newbie
  • *
  • Posts: 40
Re: I'd like to share a variable.
« Reply #6 on: August 14, 2012, 09:58:26 AM »
I seem to be giving out this link quite a bit. :)




Thank you.
It is difficult to use a variable in a script.