- Home /
How to Access GravityMultiplier from FirstPersonController.cs in UnityScript?
I'm using UnityScript and I want to be able to change the value of GravityMultiplier from the FirstPersonController.cs script from the Character Asset. How would I do this?
Answer by mwbranna · May 04, 2015 at 07:37 PM
You can create a function called SetGravityMultiplier in the C# script that does what you want, then use SendMessage to call it from a UnityScript script. You need to assign the "fpc" varible in the inspector, or using GameObject.Find(), or however else you want to do it.
public fpc : GameObject;
...
fpc.SendMessage ("SetGravityMultiplier", 5.0);
Be careful though, this can get messy quickly and has poor performance if you do it many times per frame. In general you should keep the same language for all of your scripts so you can call methods directly.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Acces C# via Unityscript 2 Answers
Distribute terrain in zones 3 Answers