- Home /
Problems with character going up on a platform(elevator)
Hi there! I'm new in Unity,i am trying to do a simple game first so i am using some of the tornado twins tutorial to do my game. The Problem i am having its basically this,i want my character to go up to a 2nd floor on a moving platform, but he just step on the platform and go right trough it, sometimes he last a sec or randoms times on it but stills falls.
I'll post both codes here, if you know a better way of doing the actions on my code i will be really thankful.
Character(its a sphere): var speed = 3.0; var rotateSpeed = 3.0; var jumpSpeed = 10.0; private var moveDirection : Vector3 = Vector3.up; var gravity = 8;
function FixedUpdate () { var controller : CharacterController = GetComponent(CharacterController);
//Move forward/backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis("Vertical");
//Rotate around y - axis
//transform.Rotate(0, Input.GetAxis("Horizontal")* rotateSpeed,0);
//When character its toching the ground and the jump button its On
if (controller.isGrounded)
if (Input.GetButton("Jump"))
{
moveDirection.y += jumpSpeed;
}
//Move forward/backward
controller.SimpleMove(forward * curSpeed);
//Jump Action
controller.Move(moveDirection * Time.deltaTime);
moveDirection.y -= gravity * Time.deltaTime;
}
@script RequireComponent(CharacterController)
The platform, im using a code that he follows an invisible cube above him:
static var Waypoint : boolean = true; var pointB : Transform; private var pointA : Vector3; var speed = 1.0;
function Start () { if(Waypoint == true) { pointA = transform.position; while (true) { var i = Mathf.PingPong(Time.time * speed, 1); transform.position = Vector3.Lerp(pointA, pointB.position, i); yield; } } }
Thanks in advance
format your code
do some searching on Unity $$anonymous$$oving Platform (https://www.google.com.au/search?q=Unity+$$anonymous$$oving+Platform)
Your answer
Follow this Question
Related Questions
Platform Mover continued 1 Answer
Moving Forward with an Animated Spirit (So to speak) 1 Answer
Character Disorder [Help pls] 0 Answers
Character on Moving and Rotating Platform 0 Answers
Anim files lose animations when passing project to partner 1 Answer