Game Development Reference
In-Depth Information
47.
48.
//Set the launch position to the point on the ray that
49.
//has the same distance from the camera as the projectile
50.
launchPosition = cameraRay.GetPoint (dist);
51.
52.
//Update line start and end positions
53.
//Line starts at the position of the projectile
54.
line.SetPosition(0, transform.position);
55.
56.
//Line ends at the launch position
57.
line.SetPosition(1, launchPosition);
58.
59.
//After drawing the line, make sure that projectile
60.
//and lanunch position has the same z position
61.
launchPosition.z = transform.position.z;
62.
}
63.
}
64.
65.
//Called when a mouse button is pressed on the object
66.
void OnMouseDown(){
67.
mousePressed = true;
68.
}
69.
70.
//Called when a mouse button is released
71.
//and the same button has been already pressed in the object
72.
void OnMouseUp(){
73.
//Projectile must not has been alread launched
74.
if(!launched){
75.
//Set launched to true and destroy the line com-
ponent
76.
launched = true;
Search WWH ::




Custom Search