Does anyone know how the Hunter in TF4 works?

This forum is for discussing shmup development, tools, engines and techniques.
Posts: 4
Joined: Sun Aug 11, 2013 7:04 pm

Does anyone know how the Hunter in TF4 works?

Postby Zero-2 » Mon Aug 12, 2013 2:18 am

I recently made a Unity project inspired by Thunder Force IV to help me figure out how Unity works, but I'm having trouble figuring out how the Hunter from TF4 homes in on enemies.

From what I've seen, it's not a simple "gradually change angle until facing the enemy" movement. It tends to speed up, slow down, go backwards, and take weird, curving, sometimes roundabout paths.

Does anyone have any ideas as to how the Hunter works?

Site Admin
User avatar
Posts: 240
Joined: Thu Jul 26, 2012 2:32 pm
Location: Melbourne

Re: Does any know how the Hunter in TF4 works?

Postby monoRAIL » Mon Aug 12, 2013 2:51 am

I haven't played TF4, could you link a video to show this weapon's behaviour?

Posts: 4
Joined: Sun Aug 11, 2013 7:04 pm

Re: Does any know how the Hunter in TF4 works?

Postby Zero-2 » Mon Aug 12, 2013 3:22 am

As it turns out, I have several videos demonstrating the Hunter weapon! :D

I'm putting one of the videos on dropbox as an avi, and will leave a download link. If I put it on Youtube, it'll cut the frame rate down to 30 fps and the Hunter's movement's will be a little harder to track.

Edit:
Here's a demonstration of the Hunter on Ratt Carry, the Stage 3 (Air Raid) boss of TF4.
(Note: File size is 43.3 MB)

Site Admin
User avatar
Posts: 240
Joined: Thu Jul 26, 2012 2:32 pm
Location: Melbourne

Re: Does anyone know how the Hunter in TF4 works?

Postby monoRAIL » Mon Aug 12, 2013 7:10 am

Very interesting fire patterns. It seems like it's breaking down to a few basic rules.

  • Emit with a forward velocity (slightly randomized to spread them out).
  • Trace a line to the target point (which is a point on the top of the enemy boss)
  • If the line is not occluded (ie there's nothing blocking line-of-sight) then accelerate to the target point.
  • If the line is occluded, then accelerate to a different point, which forms a triangle with the current position and the target point, giving a longer, curved path to the target.

There are occasional glitches though where shots seem to start off flying backwards, or where shots find they've reached the point of the triangle but the target is still occluded, so they go off on a second triangle (this makes for nice curves where the shots fly all the way round the front and top of the enemy to hit it on the back).

Posts: 4
Joined: Sun Aug 11, 2013 7:04 pm

Re: Does anyone know how the Hunter in TF4 works?

Postby Zero-2 » Wed Nov 23, 2016 5:46 pm

A few days ago, I randomly figured out how the Hunter from TF4 worked! It's actually far simpler than it looks!
After some prototyping, I was able to reproduce the Hunter's bullet movements with this:
Code: Select all
//Fields
public Vector3 directionVector = Vector3.right; //Stores the direction is this bullet supposed to be going.
public float bulletSpeed = 100f;                     //How fast is the bullet in units/sec?
public float homingSpeed = 3f;                     //How quickly does the direction change over time?

//Get the direction from the bullet's position to the goal position.
Vector3 directionToGoalNorm = (goalPosition - transform.position).normalized;

//Where the magic happens! Yes, it even works in 3D!
directionVector.x = Mathf.Lerp(directionVector.x, Mathf.Sign(directionToGoalNorm.x), Time.deltaTime * homingSpeed);
directionVector.y = Mathf.Lerp(directionVector.y, Mathf.Sign(directionToGoalNorm.y), Time.deltaTime * homingSpeed);
directionVector.z = Mathf.Lerp(directionVector.z, Mathf.Sign(directionToGoalNorm.z), Time.deltaTime * homingSpeed);

//Clamp the direction, so it doesn't go 40% faster diagonally.
directionVector = Vector3.ClampMagnitude(directionVector, 1f);

//Update Position
transform.position += (directionVector * bulletSpeed * Time.deltaTime);

It's a beautiful and mesmerizing effect to watch (for some reason)!

Return to Development

Who is online

Users browsing this forum: No registered users and 6 guests