Hello Guys,
I have been scratching my head a bit with that one. I feel like it’s a trivial one to do:
“Making sure you’re actor stays within Camera/Screen boundaries”
What I have tried is:
- Get the offset I want to apply from keyboard or gamepad
- Get the actor World location, and add that offset
- Use the node Convert World Location To Screen location
- Check X/Y are superior to 0,0 and are lower than the X/Y returned by the Node Get Viewport Size.
- It seems to work for top, left and bottom (with some gap), but checking the right border doesn’t seem to work.
I have attached screenshots to illustrate the issue.
So I have a couple of questions:
- Obvious, but do you have a clue why it’s behaving like that: gap and the right border issue
- Is there a better/more optimised way to make sure your actor stays within boundaries (Which I assume is the Viewport, but seems to not be the case)
- Is it because the camera is Perspective that I get this weird behaviour or because the way to do this check should be done in a completely different manner.
I used to work more on 2D games, so it was more or less how I would do it. Sorry if that was dumb.
Thank you,
Chris


