I'm actually working to translate a unity project originally in UnityScript to C#. I already have translated a good part of the project, but i'm confronted to some problems :
The first problem is linked with yield :
yield Attack();
yield;
I already replaced all the : yield WaitForSeconds() but I don't know how to replace this.
Secondly another problem with transform.position :
transform.eulerAngles.y += Input.GetAxis("Horizontal") * speedIdleRotate;
transform.position.y = currentHeight;
Throw the error:
UnityEngine.Transform.eulerAngles is not a variable
UnityEngine.Transform.position is not a variable
It's seem that .y is not considered, but in js I'ts working fine. How to deal with that in C#?
In JS,
yield; // this means that wait for one frame
In C#,
yield return null;
I am not 100% sure but for yield Attack();
It should be
yield return Attack();
For,
transform.eulerAngles.y += Input.GetAxis("Horizontal") * speedIdleRotate;
Try this:
transform.eulerAngles = new Vector3( transform.eulerAngles.x , transform.eulerAngles.y + Input.GetAxis("Horizontal") * speedIdleRotate , transform.eulerAngles.z);
For,
transform.position.y = currentHeight;
Try this:
transform.position =new Vector3(transform.position.x,currentHeight,transform.position.z);
Sorry if I have something wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With