This is my player script…
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Controller2D))]
public class Player : MonoBehaviour {
public float jumpHeight = 4;
public float timeToJumpApex = .4f;
float accelerationTimeAirborne = .2f;
float accelerationTimeGrounded = .1f;
float moveSpeed = 8;
float gravity;
float jumpVelocity;
Vector3 velocity;
float velocityXSmoothing;
Controller2D controller;
void Start() {
controller = GetComponent ();
gravity = -(2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2);
jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
print ("Gravity: " + gravity + " Jump Velocity: " + jumpVelocity);
}
void Update() {
if (controller.collisions.above || controller.collisions.below) {
velocity.y = 0;
}
Vector2 input = new Vector2 (Input.GetAxisRaw (“Horizontal”), Input.GetAxisRaw (“Vertical”));
if (Input.GetKeyDown (KeyCode.Space) && controller.collisions.below) {
velocity.y = jumpVelocity;
}
float targetVelocityX = input.x * moveSpeed;
velocity.x = Mathf.SmoothDamp (velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below)?accelerationTimeGrounded:accelerationTimeAirborne);
velocity.y += gravity * Time.deltaTime;
controller.Move (velocity * Time.deltaTime);
}
void OnCollisionEnter2D(Collider2D other)
{
if(other.transform.tag == “MovingPlatform”)
{
transform.parent = other.transform;
}
}
void OnCollisionExit2D(Collider2D other)
{
if(other.transform.tag == “MovingPlatform”)
{
transform.parent = null;
}
}
}
AND THIS IS MY PLATFORM SCRIPT…
using UnityEngine;
using System.Collections;
public class MovingPlatform : MonoBehaviour {
public GameObject platform;
public float moveSpeed;
private Transform currentPoint;
public Transform[ ] points;
public int pointSelection;
// Use this for initialization
void Start () {
currentPoint = points[pointSelection];
}
// Update is called once per frame
void Update () {
platform.transform.position = Vector3.MoveTowards(platform.transform.position, currentPoint.position, Time.deltaTime * moveSpeed);
if(platform.transform.position == currentPoint.position)
{
pointSelection++;
if(pointSelection == points.Length)
{
pointSelection = 0;
}
currentPoint = points[pointSelection];
}
}
}
PLEASE HELP ME?!?!?!?!?