Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: choi on August 09, 2012, 11:24:58 PM

Title: I'd like to share a variable.
Post by: choi 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.
Title: Re: I'd like to share a variable.
Post by: jeanfabre 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
Title: Re: I'd like to share a variable.
Post by: choi 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();
   }
}
------------------------------------------------------------------------------------------------------------------
Title: Re: I'd like to share a variable.
Post by: jeanfabre 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
Title: Re: I'd like to share a variable.
Post by: choi on August 11, 2012, 09:17:13 PM
Thank you.
Is there work to see a sample?  :'(
Title: Re: I'd like to share a variable.
Post by: amaranth on August 11, 2012, 11:34:13 PM
I seem to be giving out this link quite a bit. :)


Title: Re: I'd like to share a variable.
Post by: choi 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.