- Home /
 
Why when set gameobject children he changes the movement behavior
Why do I set my gameObject as the child of another game object to have its behavior change?
I have the following points:
1 - I define that my player is the child of a platform that moves upwards (so that he can follow the movement).
2 - My horizontal movement is impaired. I feel like my character slows down on the platform ... even though I do not change any of his properties (I just define him as the platform child).
3 - My character is moved with rigidbody2d and my platform is moved only by transform (animation).
4 - When I set the "Interpolate" property to "None" the character's movement returns to normal, however, I need my rigidbody2d to have the "Interpolate" property set to "Interpolate" in the course of my game.
5 - When I add a rigidbody to the platform, I have a problem with the "overlap colliders".
Is there anything I'm doing wrong?
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);
   
      }
  }
 
               Every help is welcome!
Your answer