I want make pong tennis game and thi is supposed to be control of one platforms and 2p01 is name of colider i have this code connect with the platform. Can you help me?
Please help me with this code I have connect it to
private var ray : Ray;
private var hit : RaycastHit;
function Update () {
if(Input.GetMouseButton(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, hit))
{
if (hit.collider != "2p01")
{
Move ();
}
}
}
}
function Move()
{
transform.position.x = ray.point.x;
}
}
ok... what are trying to "connect" to, what do you mean by connecting? (for all we know you trying to connect a face chat with Kristen Stewart)what are you having problems with? if you wondering where to Attach the script. attach to the 2p01 game object in your hierarchy and test it. if its not working or you get errors reply via the comments section.
– Fornoreason1000*I have problem with moving eith platform.
– Nexgeayou didn't put the code in a Boo script did you?, that above is UnityScript(or Javascript). (does the icon in the Project window have a little Pacman ghost on it?)
– Fornoreason1000Ray's don't have a 'point'. I'm guessing you want 'hit.point';
– robertbu