Question by
$$anonymous$$ · Aug 13, 2021 at 10:02 AM ·
c#2dmovementmovement scriptisometric
Isometric movement for MoveTowards
I'm having a fair but of trouble here. I am tying to figure out how in the world could I use MoveTowards for Isometric movement. I've tried countless things and have faced countless errors but a lot of these are that the player movement just doesn't change even when I change the math. Here is what I have:
void Update(){
// Converting Unity's Cartisan Movement to Isometric----//
//
carMove.x = Input.GetAxisRaw("Horizontal");// //
carMove.y = Input.GetAxisRaw("Vertical");// //
//
isoMove.x = carMove.x - carMove.y;// //
isoMove.y = (carMove.x + carMove.y) / 2;// //
//
//--------------------------------------------------------
if(Vector3.Distance(transform.position, movePoint.position) <= 0.05f){
if(Mathf.Abs(Input.GetAxisRaw("Horizontal")) == 1f){
movePoint.position += new Vector3(Input.GetAxisRaw("Horizontal") - Input.GetAxisRaw("Vertical"), 0f, 0f);
}
if(Mathf.Abs(Input.GetAxisRaw("Vertical")) == 1f){
movePoint.position += new Vector3(0f, Input.GetAxisRaw("Vertical") / 2 , 0f);
}
}
transform.position = Vector3.MoveTowards(transform.position, movePoint.position, moveSpeed * Time.deltaTime);
Debug.Log(movePoint.position.x);
}
You can see in the comments where I have tried some of the other things out but I am still stuck and cannot move it. Any help in this regard would be amazing. This is a 2d project by the way
Comment