- Home /
Question by
jesseblakemccann · Jan 31, 2021 at 09:09 PM ·
speedvector2movetowardsmovepositionvector3.movetowards
Adjust the speed of an individual axis when using MoveToward,Adjust the speed by individual axis usingMoveToward
Hello! I'm trying to use the MoveToward function to move toward the player, but I want the speed that it moves along x and the y axis to be different. As far as I can tell, you can only apply one speed. Anyone have any idea how I can adjust the speed for an individual axis?
This is what I have so far:
transform.position = Vector2.MoveTowards(transform.position, new Vector2(playerPosX, playerPosY), speed * Time.deltaTime);
Comment
Best Answer
Answer by jesseblakemccann · Jan 31, 2021 at 11:15 PM
Solved-- I instead used RigidBody component, where I can adjust the linear and angular drag.
_rigidbody.AddForce((player.transform.position - transform.position) * speed);