I need somebody to help me convert this to .js, i have attempted to change a different code from .cs to .js using a converter but I don’t know how to code so I was just wondering if somebody could help me, anyways if you know how to do this please help. Thank you.
"using UnityEngine;
using System.Collections;
public class ShootSound : MonoBehaviour {
public AudioSource someSound;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Mouse0)) {
someSound.Play ();
}
}
}
"
Here are few things you have to do in order to convert the code:
- In all variables, move their type after the name of the variable and add a column between the name and the type. So in your case
AudioSource someSound should be written as someSound : AudioSource
- Then, you have to change all voids to function. If it is a float or bool, you have to change it to function and add
: returnType just before the {. Keep in mind, that booleans in JS are Boolean and in c# bool.
- In the functions you also have to change the input variables the same way you do in 1).
- If the c# script is not MonoBehaviour, then change the
: to extends. Otherwise, you can just remove the class line.
- All
using should be replaced with import.