This is my player’s movement script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float movementSpeed;
public Transform movePoint;
public LayerMask obstacle;
public bool canMove;
void Update()
{
transform.position = Vector3.MoveTowards(transform.position, movePoint.position, movementSpeed * Time.deltaTime);
if (Vector3.Distance(transform.position, movePoint.position) <= 0.05f)
{
if (Mathf.Abs(Input.GetAxisRaw(“Horizontal”)) == 1f)
{
if (!Physics2D.OverlapCircle(movePoint.position + new Vector3(Input.GetAxisRaw(“Horizontal”), 0f, 0f), 0.2f, obstacle) && canMove)
{
movePoint.position += new Vector3(Input.GetAxisRaw(“Horizontal”), 0f, 0f);
}
}
else if (Mathf.Abs(Input.GetAxisRaw(“Vertical”)) == 1f)
{
if (!Physics2D.OverlapCircle(movePoint.position + new Vector3(0f, Input.GetAxisRaw(“Vertical”), 0f), 0.2f, obstacle) && canMove)
{
movePoint.position += new Vector3(0f, Input.GetAxisRaw(“Vertical”), 0f);
}
}
}
}
}
Is there an effective way I can make pushable objects that sync with the player’s movements? I tried using triggers but they didn’t work.