2D enemy wave that the player can ride on but the front kills them in and endless runner.
Hi there, making my first game to learn how to use Unity with my friend doing art and animation.
I've been following this tutorial James Plus Games Endless Runner tutorial. Which has been great so far, but we wanted to change the gameplay slightly to make it more interesting.
In the original, the player is jumping from platform to platform and if they miss and hit the floor a 2d collider is killing the player via a tag of "killbox". We decided we wanted make our player a dinosaur that’s surfing along and instead of jumping on platforms we want him jumping over waves. To mix up things we wanted to make it so that if you hit the front of the wave it kills the player and if you hit the top of the wave it acts as the ground. So the player can effectively ride the top of the wave.
So in our game the floor doesn't hurt you but the front of the waves do. The camera follows the player so in the original the game objects are made active from a pool and the appearance of movement is given by the camera moving. But with the waves we wanted to move them so it looks more like they are coming toward the player. Which we can get working fine, using either waypoints using transform.position or using the constantforce2D component both options have their pro's and cons but in both I can only get the wave to either kill the player or alternatively the player can ride top like ground.
Things I've tried:
Making parent game object with two children game objects, once that’s got the "killbox" tag and one with the "grounded" layer.
And also one game object where the parent is either the killbox or the platform and visa versa.
But no matter what combination I try the wave is always either a killbox or the ground.
This is the logic for the player that checks if they have hit the killbox tag:
void OnCollisionEnter2D (Collision2D other)
{
if (other.gameObject.tag == "killbox") {
theGameManager.RestartGame();
moveSpeed = moveSpeedStore;
speedMilestoneCount = speedMilestoneCountStore;
}
If you need anything clarifying then please let me know. Sorry if this seems like a silly question but I've been banging my head against this for quite awhile now and any help anyone can suggest is seriously appreciated.
Cheers Harry
Answer by barrycook · Mar 08, 2018 at 11:39 AM
Hi so I think the process of writing all this out basically helped the puzzle in my brain click into place. It was a case of my waypoints being prefabs, but also a child of the Camera object so that they had a static position.
And also the wave object being the ground and its child being the killbox. Both with 2d box colliders and neither having a ridgidbody2d component.
If anyone in the future is trying to solve a similar issue just let me know and I'll see if I can help.
All the best, Harry
Your answer
Follow this Question
Related Questions
Object pooling system. Objects aren't spawning 0 Answers
Player Can walk through walls [2D] 1 Answer
2D Character gets stuck on boxes. 1 Answer
2D Collision Point 0 Answers
On 2D platformer, how to have the screen going after the player? 0 Answers