David_3
February 10, 2011, 3:31pm
1
Hey,
I want to create a fly-through effect as if the user was controlling a helicopter with the following controls:
mouse points direction of travel
up/down arrow = travel in direction pointed
I've tried to do this with a 3dwalker but failed. Is there a built in script i can use to do this?
David
David_3
February 10, 2011, 5:43pm
2
// Click To Move script
var change:double = 3; // Determines how quickly you move
private var targetPosition:Vector3;
function Update () {
var scroll = Input.GetAxis("Mouse ScrollWheel");
if (scroll !=0) {
change += scroll;
if (change <0.1) {
change = 0.1;
}
}
if (Input.GetMouseButton(0)) {
transform.position = transform.position+Camera.main.transform.forward *change ;
}
if (Input.GetMouseButton(1)) {
transform.position = transform.position-Camera.main.transform.forward *change ;
}
if (transform.position.y <0) {
transform.position.y = 0;
}
}
attach to your fps walker
hold down left mouse button to move in the direction you point... turn off gravity for hover effect
system
July 25, 2011, 8:31am
3
guy this script really work…but i have problem with colider. whenever i click, the FPS will go through the concrete object (colider). do u have any idea for these? thanks David