- Home /
This question was
closed Feb 20, 2014 at 09:47 PM by
Graham-Dunnett for the following reason:
Question is off-topic or not relevant
Question by
Agriggs · Feb 20, 2014 at 07:39 PM ·
beginnerjava to c#
I need help with C#
i need help converting my java script code into c# can anyone help me? below is what ive converted into c# from java script.
using UnityEngine; using System.Collections;
public class Ballcontrol : MonoBehaviour { public int rotationSpeed = 100; public int jumpHeight = 8; private bool playOnce = true; public AudioClip Hit01; public AudioClip Hit02; public AudioClip Hit03; private bool isFalling = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
{
//Handle ball rotation.
rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.W) && isFalling == false)
{
rigidbody.velocity.y = jumpHeight;
playOnce = True();
}
isFalling = true;
}
void OnCollisionStay ()
{
if (playOnce == true)
{
var theHit = Random.Range(0, 4);
if (theHit == 0)
{
audio.clip = Hit01;
}
else if (theHit == 1)
{
audio.clip = Hit02;
}
else {
audio.clip = Hit03;
}
audio.pitch = Random.Range (0.9,1.1);
audio.Play();
playOnce = false;
}
isFalling = false;
}
void playOnceTrue () {
yield return new WaitForSeconds(0.2);
playOnce = true;
}
}
}
Comment
This converts it!
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Left Click to Play Audio Help? 0 Answers
Why do these errors keep showing up with C#? Im a beginner with coding 1 Answer
[Answered]Rigid body Movement C# 0 Answers