can someone pls help me. c# to js
I just now the basics of c# but for me this is advance. So could someone translate or give me suggestions?
using UnityEngine; using System.Collections;
public class raycast : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
RaycastHit hit;
Ray downray = new Ray (transform.position, Vector3.forward);
Debug.DrawRay (transform.position, Vector3.forward * 10, Color.green);
if(Physics.Raycast (downray, out hit, 10))
{
if(hit.collider.tag=="Player")
{
Debug.Log("Hit player");
Debug.Log(hit.distance);
}
}
}
}
Comment
Answer by TheFloatingSheep · Jun 25, 2016 at 10:05 AM
function Update () {
var hit : RaycastHit;
Debug.DrawRay(transform.position, Vector3.forward * 10, Color.green);
if(Physics.Raycast(downray, out hit, 10)){
if(hit.collider.tag == "Player"){
Debug.Log("Hit player");
Debug.Log(hit.distance);
}
}
}
Your answer
Follow this Question
Related Questions
Convert Js yo C# 1 Answer
Convert Keyboard controlls to UI Buttons 1 Answer
Why doesn't the collider work? 1 Answer
player collider translate 0 Answers