- Home /
2D boomerang effect
Hello,
I'm currently working on a 2D game with a top-down view of a static player throwing a sword towards enemies. I have managed to make the sword lunge and spin based on the distance you drag your mouse but I can't manage to make it come back to the player after reaching its maximum "y" value. How would I create that function? I'm new to C# and have mostly worked with GML and Javascript.
I appreciate your answers!
Comment
Answer by highpockets · Mar 19, 2019 at 07:21 AM
You can use:
float timeCount = 0.0f;
void Update(){
sword.transform.position = Vector2.Lerp(endPosition, playerHandPosition, timeCount);
timeCount = timeCount + Time.deltaTime;
}
You can use this lerp function to have the sword thrown out towards the enemies as well. I don’t know how you did so.