I am super stuck on making a jumping script for my player. I am creating a kind of "rolling jump’ clone (Rolling Jump review (iPod/iPhone) | ArcadeLife : Life vs Video Games) and I want the player to be able to jump on rotating cylinders, and then jump off in the opposite direction of the floor. I have tried to use raycastHit to find the normal of the ground, onCollisionStay, eulerAngles, transformDirection but as I am not very good at coding i’m finding it hard to integrate bits together.
Below is a drawing of what I want to achieve, but with gravity still so if the player jumps towards nothing it will fall to the ground.
At the moment I’m using fixed joints to attach the player to the rotating platforms, by creating it on collision.

Here is my current code:
private var myNormal: Vector3;
private var distGround: float;
private var turnAngle: float = 0;
function Start (){
myNormal = transform.up;
}
function Update () {
var up = transform.TransformDirection(Vector3.up);
var ray : Ray;
var hit : RaycastHit;
Debug.DrawRay(transform.position, -up * 10, Color.green);
var fingerCount = 0;
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
fingerCount++;
}
if (fingerCount > 0){
rigidbody.velocity = Vector3.up * minHeight;
print ("User has " + fingerCount + " finger(s) touching the screen");
ray = Ray(transform.position, -myNormal);
if (Physics.Raycast(ray, hit)){ // use it to update myNormal and isGrounded
isGrounded = hit.distance <= distGround + deltaGround;
myNormal = Vector3.Lerp(myNormal, hit.normal, Time.deltaTime);
}
var turn = Input.GetAxis("Mouse X") * turnSpeed * Time.deltaTime;
turnAngle = (turnAngle + turn) % 360;
var rot = Quaternion.FromToRotation(Vector3.up, myNormal);
rot *= Quaternion.Euler(0,turnAngle,0); // and to current direction
transform.rotation = rot;
}
}
I’ve looked at many other questions and answers but none of them seem to work for me, does anyone have any ideas or answers? This has been driving me crazy for ages!
Thanks
SO, if you want to move it with some input just have for every cycle you press left or right you move +/- the incr value which you add onto the angle, to give a rotating effect about the center of your screen.
– cdrandinSorry, I forgot to say that my platforms already rotate, which I have done with animations. I can jump from platform to platform but when the player jumps there is only movement on the Y axis, even if the player is on the side of the platform. Thanks for your answer though!
– alb917