Question by
unoo_ · Mar 07, 2019 at 01:26 PM ·
moveposition
MovePosition() at the same time doesn't work
public class Script : MonoBehaviour
{
void Start()
{
StartCoroutine(A(GetComponent<Rigidbody2D>()));
}
private IEnumerator A(Rigidbody2D rb)
{
yield return null;
rb.MovePosition(rb.position + Vector2.left);
Debug.Log("A");
}
}
I attached this script twice to an object. When I play the scene, the object moves only one unit left. I think that calling MovePosition() on the same frame, on the two separated behaviour makes something wrong. What can I do to make all MovePosition() applied?
Comment
i have copied your code and add 2 times the script and worked fine tranlating 2 units.
Your answer
![](https://koobas.hobune.stream/wayback/20220612193127im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Choppy camera, moving player in FixedUpdate and enemies through navmesh 0 Answers
Moving a cube with RigidBody. MovePostition, it randomly stops moving 0 Answers
Get the distance of a touch while touch phase is moved 2 Answers
Rigidbody.MovePosition doesn't work on selective objects. 2 Answers
gameObject can't move and collide after setting it off and setting it on again. 0 Answers