Hey I actually tried implementing this in UE5 but got really confused...Can you plz explain me its logic of implementation...Or is there any way we can connect?
Viewing post in Connect jam comments
Hey there. The way I approach it is to...
- Check for "opposite" PipeDirection value between the CurrentPipe and the NextPipe to validate pipe connection
- Check for "other" PipeDirection of the current connected pipe to determine the next pipe we need to validate
Use Enum BitFlags to define each Pipe direction. This allows multiple enum combination. A straight horizontal pipe {PipeDirection.Left | PipeDirection.Right} where the NextTile is positioned on the Left can connect to any PipeDirection.Right enum combination (Up | Right, Down | Right, Left | Right). Use EnumHasAnyFlags to check if the NextPipeDirection has any "opposite" value of the CurrentPipeDirection.
Have a method to handle GetOppositeDirection(PipeDirection dir), which returns the opposite PipeDirection needed.
Each pipe instances store information of its neighbouring pipe instance based on their positions (Top, Down, Left, Right) as a way to navigate the NextPipe we should validate the connection with. To get the "other" PipeDirection, use & ~ Value to isolate the connected PipeDirection enum value.
Hope this helps. Good luck on you project.