Skip to main content
added 13 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is no longer able to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2 did and have the follower just try anyway, die, and then miraculously return after a short while. But that kind of slapstick humor might not be appropriate for the theme of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is no longer able to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2 did and have the follower just try anyway, die, and then return after a short while. But that kind of slapstick humor might not be appropriate for the theme of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is no longer able to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2 did and have the follower just try anyway, die, and then miraculously return after a short while. But that kind of slapstick humor might not be appropriate for the theme of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

added 5 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

This script is just a very simple proof-of-concept. It only copies the position, but you likely also want it to copy the player's rotation (or at least the direction it faces), what action it performs (walking, jumping, etc.) and also handle a couple other edge cases specific to your game. So you will likely need to record more in the queue than just a Vector3. If that is the case, create your own struct type with all the data you need and use that as the type of your queue.

It might get even more complicated if you don't just want the followers to move onto the exact position of the leader but leave them some personal space when standing. The naive solution would be to just not dequeue the next action if the distance to the leader is too short. But this could lead to some weird situations. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air. Or alternatively you could have certain "uninterruptible" actions like jumping and have the follower ignore the minimum distance during these actions.

This script is just a very simple proof-of-concept. It only copies the position, but you likely also want it to copy the player's rotation (or at least the direction it faces), what action it performs (walking, jumping, etc.) and also handle a couple other edge cases specific to your game. So you will likely need to record more in the queue than just a Vector3. If that is the case, create your own struct with all the data you need and use that as the type of your queue.

It might get even more complicated if you don't just want the followers to move onto the exact position of the leader but leave them some personal space when standing. The naive solution would be to just not dequeue the next action if the distance to the leader is too short. But this could lead to some weird situations. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air.

This script is just a very simple proof-of-concept. It only copies the position, but you likely also want it to copy the player's rotation (or at least the direction it faces), what action it performs (walking, jumping, etc.) and also handle a couple other edge cases specific to your game. So you will likely need to record more in the queue than just a Vector3. If that is the case, create your own struct type with all the data you need and use that as the type of your queue.

It might get even more complicated if you don't just want the followers to move onto the exact position of the leader but leave them some personal space when standing. The naive solution would be to just not dequeue the next action if the distance to the leader is too short. But this could lead to some weird situations. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air. Or alternatively you could have certain "uninterruptible" actions like jumping and have the follower ignore the minimum distance during these actions.

added 158 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342

It might get even more complicated if you don't just want the followers to move toonto the exact position of the playerleader but keepleave them some respectpersonal space when standing. The naive solution would be to just not dequeue the next action if the distance to the leader is too short. But this could lead to some weird situations. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air.

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is unableno longer able to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2Sonic 2 did and have the follower just try anyway, die, and then return after a short while. But that kind of slapstick humor might not be appropriate for the settingtheme of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

It might get even more complicated if you don't just want the followers to move to the exact position of the player but keep some respect distance. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air.

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is unable to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2 did and have the follower just try anyway, die, and then return after a while. But that kind of slapstick humor might not be appropriate for the setting of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

It might get even more complicated if you don't just want the followers to move onto the exact position of the leader but leave them some personal space when standing. The naive solution would be to just not dequeue the next action if the distance to the leader is too short. But this could lead to some weird situations. For example, if the player jumps, you might not want the follower to stop mid-air. You might want them to wait until the player completed the jump. So you might want to use record.Peek() to look at the next action in the queue without removing it and if you find that it is a "start to jump" action, then don't dequeue it while the leader is still in the air.

And then there is the question: Do you want the follower to be able to fail? You could give it its own collision physics, but then you will have situations where the follower is no longer able to do what the leader did (like jumping on a moving platform which isn't there anymore). What happens now? You could do it like Sonic 2 did and have the follower just try anyway, die, and then return after a short while. But that kind of slapstick humor might not be appropriate for the theme of every game. If you want the followers to act more competently, then you will have to implement 2d platformer pathfinding. But this can get really complicated, especially with changing environments.

added 63 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
added 63 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
Post Undeleted by Philipp
added 63 characters in body
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading
Post Deleted by Philipp
Source Link
Philipp
  • 121.5k
  • 28
  • 261
  • 342
Loading