Hey all!
Having sprite trouble (again). In a nutshell, I am setting up animations and events to play out in a specific order. Animation events are used to tell the player object to transition between animations and move in a certain way. The issue I am having is that the movement isn’t working. My player object plays the appropriate animation, but it isn’t moving and so it locks up the rest of the scripts.
The script I am using for movement is based on locating the nearest drop-off point. Essentially, I have it so the pickup animation is played. Once that is done, it executes the Transporter function. The animation (which loops) for transporting has an event for ToDrop. ToDrop should then transition to Dropper as shown below, which plays an animation and then goes back to idle, giving the player control over the player object.
Whatever is breaking appears to be in Transporter, as the game object just gets stuck in the animation and never moves. Thus ToDrop and Dropper are never initialized.
public void Transporter()
{
playerHand.SetBool("toPit", true);
playerHand.SetBool("handCatch", false);
// This is the part that seems to not work.
var nearestPit = Pit.FindClosestPit(transform.position);
transform.position = Vector2.Lerp(transform.position, nearestPit.transform.position, moveSpeed);
Vector2 difference = nearestPit.transform.position - transform.position;
handBody.position = new Vector2(handBody.position.x, handBody.position.y);
}
public void ToDrop()
{
var nearestPit = Pit.FindClosestPit(transform.position);
if (gameObject.transform.position == nearestPit.transform.position)
{
Dropper();
}
}
public void Dropper()
{
playerHand.SetBool("droppping", true);
playerHand.SetBool("toPit", false);
playerHand.SetBool("handCatch", false);
}
Am I missing a Vector in here somewhere?