- Home /
onMouseUp, motion velocity
Hello People
I'm making a game for tablets (i.e. gesture input) I have one finger (mouseDown) Scrolling the camera past Text, when the user lets go (onMouseUp) I want the camera to keep tracking a bit before it comes to a stop and executes the onMouseUp script which sends them to another galaxy (in the same Level).
In those few seconds, the user will have the option to click and go to something else before the mouseUp Script kicks in and pushes them to another galaxy
Here is the LOGIC of my js Code:
// variables I use to Lerp the Camera from one point to another
var camPos : Vector3;
var endPos : Vector3;
onMouseup () {
// what I am having problem coding:
if Camera is moving right, let it gradually coast to a stop on the right;
goGalaxy9;
if Camera is moving left, let it gradually coast to a stop on the left;
goGalaxy9;
}
goGalaxy9 () {
// this works to Lerp the Camera from one point to another
endPos = Vector3( Camera.main.transform.position.x, Camera.main.transform.position.y, Camera.main.transform.position.z);
var i = 0.0;
var rate = 1.0/time;
while (i < 1.0) {
i += Time.deltaTime * rate;
Camera.main.transform.position = Vector3.Lerp( endPos, camPos, i);
yield;
}
Camera.main.transform.position = Vector3.Lerp( endPos, newPos, i);
yield;
}
Make sense?
Anyway, thanks for checking this out. It's very fun and the community here has been so supportive
Thank you
~Be
Comment
Been trolling around to no avail...Would it be something like..?:
function Update () {
move.AddForce(tranform.forward * speed);
}
Ideas? Thnx