URGENTLY IN NEED OF HELP!!!!
Hi all,
Recently my boss bought a starterkit by activeden called Active Jump!
I have been trying to get it port into iphone/android with no success...
well here is the code, this is attached to the player prefab.
Basically i need to tilt the phone left to right like those jumping game clones on iphone & android.. aka like Abduction, doodle jump, papi jump etc etc...
i tried so far but no avail, keep getting errors like float cannot convert into vector3 stuff like that.. usually this is my last resort posting here...
PS: this is a part of the full code.. i hope im not voiding any stupid license from Activeden...
private var theZ : float;
private var jumpEnabled : boolean;
private var canMove : boolean;
private var hit : RaycastHit;
private var mousePos : float;
private var xVel : float;
private var xPos : float;
private var yVel : float;
function FixedUpdate () {
// always assume we're NOT grounded every step (and expect to be proved wrong by raycasting etc.)
grounded=false;
// check to see if we're on top of a platform - here we cast two rays, one on each side of the player
// LEFT:
if (Physics.Raycast (transform.position- Vector3.up * 0.5
+ Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
// we found ground, so set our grounded flag to true, so that the player will jump
grounded=true;
if(rigidbody.velocity.y<0){
theTransformHit=hit.transform;
}
}
// RIGHT:
if (Physics.Raycast (transform.position- Vector3.up * 0.5
- Vector3.right * 0.5, -Vector3.up, hit, 1, 1<<9)) {
// we found ground, so set our grounded flag to true, so that the player will jump
grounded=true;
if(rigidbody.velocity.y<0){
theTransformHit=hit.transform;
}
}
// do jumping, if we're on top of a platform
if(jumpEnabled){
if(grounded && rigidbody.velocity.y<0){
doJump();
// send a message to the platform to tell it to destroy itself
theTransformHit.gameObject.SendMessage("hitPlatform");
}
}
// grab the mouse position and take off the width of the screen /2 so that moving the
// mouse to the left of the window will produce a negative number and moving it to the right of
// the window will produce a positive number
mousePos = (Screen.width/2)-Input.mousePosition.x;
// now we check the mouse position and move our player accordingly
xVel=0;
if (mousePos>1 || mousePos<-1){
xVel+=(mousePos*0.02);
}
if(canMove){
// add x velocity to our position
//xPos=transform.position.x;
if(xVel>maxMoveSpeed)
xVel=maxMoveSpeed;
if(xVel<-maxMoveSpeed)
xVel=-maxMoveSpeed;
if(xPos>gameWidth){
xPos=gameWidth;
rigidbody.MovePosition(Vector3(gameWidth,transform.position.y,transform.position.z));
if(xVel>0){
xVel=0;
rigidbody.velocity.x=0;
}
}
if(xPos<-gameWidth){
xPos=-gameWidth;
rigidbody.MovePosition(Vector3(-gameWidth,transform.position.y,transform.position.z));
if(xVel<0){
xVel=0;
rigidbody.velocity.x=0;
}
}
// set our movement velocity
rigidbody.velocity.x=xVel*5;
// lean our player some
transform.eulerAngles.z=-(mousePos*0.2);
}