Hi all. I am having trouble getting a raycast to go from a ship to the ground when I hold the mouse button down. Here is the script I have so far
var horizontalSpeed = 2.0;
var verticalSpeed = 2.0;
var particle : GameObject;
var myTransform : Transform;
function Update ()
{
// Get the mouse delta. This is not in the range -1...1
var h = horizontalSpeed * Input.GetAxis ("Mouse X");
var v = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Translate (v, 0, -h);
if(Input.GetMouseButton(0)){
//construct a ray from the mouse point
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if ( Physics.Raycast(myTransform.position, ray)){
Instantiate (particle, transform.position, transform.rotation);
}
//horizontalSpeed=0;
//verticalSpeed=0;
}
}
right now I get an error that says Assets/UFO.js(20,21): BCE0023: No appropriate version of ‘UnityEngine.Physics.Raycast’ for the argument list ‘(UnityEngine.Vector3, UnityEngine.Ray)’ was found. but I’m not sure where the arguments aren’t right. how can I get the raycast to go from the ship to the ground? Thanks!