- Home /
Cannot implicitly convert type `void' to `float'
Hello there...
I'm trying to obtain a variable from one JS scripy to a C# one... I've the following code for that:
float Speed = print(PlayerScript.Speed);
string speedstring = Convert.ToString(Speed);
The objective is to show the value in a GUI.Label, but the Speed variable from the JS script is returning has void... So, how to make it return as a float?
Thanks for the answer...
Answer by syclamoth · Jan 03, 2012 at 11:08 AM
There are several problems here.
First, print(value) doesn't return a float- it doesn't return anything! Why are you trying to get a value out of that? It's possible that you are getting confused here. Try splitting it into two lines-
float speed = PlayerScript.Speed;
Debug.Log(speed);
Second, I need to see more of your code to really understand what you're trying to do here. Remember that it's hard to get scripts in JS and C# to talk to each-other- it's usually easiest to just use either one language, or the other. If you have found scripts on the internet that you want to incorporate which use the wrong language, it might be worth your while to learn how to convert between them.
Actually it's a project I'm doing with a buddy of $$anonymous$$e and I use C# to code and he uses JS... And that was what I found here (check the last paragraph (I don't need to say that I've the page show me C# code)):
But yeah, it worked thanks =)
Your answer
Follow this Question
Related Questions
How to Access GravityMultiplier from FirstPersonController.cs in UnityScript? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Acces C# via Unityscript 2 Answers