Projectile Boomerang

Anyone got any good ideas for a projectile to have a boomerang effect? I’ve thought of creating an empty game object with a box collider attached and when the projectile collides with the empty game object it will return back to its instantiated position and then disappear. But then I have to calculate arc too… seems like the physics could present some problems for me as it’s not a strong point of mine. Regardless maybe someone has some suggestions or has done something similar to this? Thanks for any tips or suggestions!

Supposing all you want is the projectile to blindly follow a boomerang-like-path, you can simply set the math for an ellipsoid interpolation under Update. Here I modified the example on Slerp (even though I don’t quite understand it myself). It’s only half the path, but it works just with copy and paste:

using UnityEngine;
using System.Collections;

public class BoomerangEffect : MonoBehaviour {
	public float duration = 1; // in seconds
	
	public Vector3 beginPoint = new Vector3(0, 0, 0);
	public Vector3 finalPoint = new Vector3(0, 0, 30);
	public Vector3 farPoint = new Vector3(0, 0, 0);
	
	public bool startAgain = false;
	
	private float startTime;
	
	void Start () {
		startTime = Time.time;
	}
	
	void Update () {
		if (startAgain) Start();
		
		Vector3 center = (beginPoint + finalPoint) * 0.5F;
		center -= farPoint;
		
		Vector3 riseRelCenter = beginPoint - center;
		Vector3 setRelCenter = finalPoint - center;
		
		transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, (Time.time - startTime) / duration);
		transform.position += center;
	}
}

Thanks for the tip. I was actually looking at the Slerp example too and studying the physics of boomerangs and got stuck trying to find a way to convert the equations to code. this will definately help tho appreciate it :slight_smile: on a side note… i found a very easy way to make this work. I animated the projectile’s path in a 3d modeling program and instantiate the object and it’s associated animation at the release point for the weapon. I attached a box collider to the boomerang and just wrote a script that if my player collides with it then the death sequence will start. haha… i know it’s a cheap way of making it work… but i’ve done that for now :slight_smile: regardless appreciate this code… will definately look into it