I have a GameObject. It has the following two scripts attached:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody2D))]
public class MovePosition1 : MonoBehaviour
{
void FixedUpdate()
{
float newX = transform.position.x + 1;
float newY = transform.position.y;
Vector2 newPosition = new Vector2(newX, newY);
rigidbody2D.MovePosition(newPosition);
}
}
==========================================================
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Rigidbody2D))]
public class MovePosition2 : MonoBehaviour
{
void FixedUpdate()
{
float newX = transform.position.x;
float newY = transform.position.y + 1;
Vector2 newPosition = new Vector2(newX, newY);
rigidbody2D.MovePosition(newPosition);
}
}
But only one of the Rigidbody2D.MovePosition() calls are taking place. Why is this? How can I fix this (without combining the scripts)?