I took some time away from my main team to work on a VR game this semester. Since the start I've added features to the game to make it pop and have more dynamic movement, lets take a look at some:
Boss Development in VR:
The first step was to create a script that allowed me to spawn as many projectiles as I wanted and have them all exit from the boss, this would allow flexibility with how many enemies we want the player to face.
Moving Targets Around the Player
Afterward, I went about making targets for the enemies to follow that are offset from where the player is, they can follow any object that's needed.
These sphere targets have a player location, a radius from that location, and a height offset from the location as well.
Each sphere also has a randomized value from zero to one that's assigned to it when it's created, I can then multiply this by an over-all height or radius offset variable which lets all of the spheres "spread out" from the original radius they revolve around, as seen above. It's really satisfying to see it all work and adjust in real time.
Here's the full effect in play, it's really nice to see how the spheres spread out naturally. But this is the first step, all of the spheres being created are based on a prefab, so I went to designing that as well.
Adding Dynamic Behavior to Enemies
I wanted the movement of the prefab to be independent of it's position so I wrote a script that does the following:
Find where the object was during the last frame
get its direction by drawing a line from that position to the current one
get the angle of that direction and compare it to the current rotation of the Prefab
add a percentage of the difference in those angles each frame to "push" the object's rotation toward the wanted rotation
This worked very well, and I took the logic and applied it to another method which derives the target angle from an object's position instead of the forward vector, letting the prefab look at things while it moves.
After this was done, I put it all on a state machine so I could switch between behaviors and called it a day.