I'm having a problem similar to this link: http://answers.unity3d.com/questions/1295955/character-on-a-moving-platform-slows-down.html
But...
My 2D character is on an elevator (which does not have any physics) and is being moved up and down through an animation (transform). But when my character is on the elevator, the colliders2D overlaps another, as my character's RigidBody2D stands still as I move the game object elevator (crossing each other). My solution was to try to attach my character as the child of the elevator (SetParent), and this solved the problem of overcoming the colliders, but it gave me a new problem.
The new problem consists of a certain slowness in the movement of the character while it is on the elevator. I believe the problem is because the transform of my character is in motion while the elevator goes up and my rigidbody don't add any force.
Do I need move the elevator with physics to stay movent? Or am I thinking the wrong way?" How to solve this problem? See the player movement script:
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public float speed;
public float jump;
public GameObject rayOrigin;
public float rayCheckDistance;
Rigidbody2D rb;
void Start () {
rb = GetComponent <Rigidbody2D> ();
}
void FixedUpdate () {
float x = Input.GetAxis ("Horizontal");
if (Input.GetAxis ("Jump") > 0) {
RaycastHit2D hit = Physics2D.Raycast(rayOrigin.transform.position, Vector2.down, rayCheckDistance);
if (hit.collider != null) {
rb.AddForce (Vector2.up * jump, ForceMode2D.Impulse);
}
}
rb.velocity = new Vector3 (x * speed, rb.velocity.y, 0);
}
}