Image Update: Non-Axis-Aligned Box
《Drifting : Weight of Feathers》
Steam - Steam Page
Itch.IO - Non-Axis-Aligned Box
IndieDB - Non-Axis-Aligned Box
UE4 Forum - UE4 Forum
Non-Axis-Aligned Box
I encountered a seemingly simple mathematic problem yesterday, and trying to figure out an appropriate solution for an entire morning:
Check whether a point is inside a non-axis-aligned box
Calling UPrimitiveComponent::IsOverlappingActor() was my first attempt, however, after some thought experiments I abandon the idea for 2 reasons: first, the point is not represented as an actor (creating a collidable dummy actor will increase calculation overhead and further complicate my colliding channel); second, it will be much better performance-wise to avoid using per tick collision event if I could figure out a way to use mathematic to solve the problem.
Calling UKismetMathLibrary::IsPointInBox() was also a failed attempt since the box is non-axis-aligned, the function assumed the box is perfectly aligned with the world coordination (simply comparing the max/min x,y,z values will return incorrect results if the box is rotated). Another version of the function - UKismetMathLibrary::IsPointInBoxWithTransform() seems to do what I wanted - calling the IsPointInBox() after transforming the point from world coordinate system to component coordinate system - however, for some unknown reason (perhaps incorrect value for the input component transform?), the function still gave me the incorrect result after calling it.
(if you go through the four sides of the box clockwise, check the point is at the right of each side; Instead, if you go through the four sides counter-clockwise, check the point is at the left of each side)
I googled and found various ways to solve the problem on StackOverflow - alas, due to my poor math grade in high school, I cannot comprehend the logic behind all these clean and clever solutions! I was hesitant to add these methods to my project before gaining an understanding of how it works. After some more failed attempts to try and understand the online solutions, one of the solution gave me an idea of how to (partially) solve the problem:
Check the point is at the right of each side of the box in 2D, then compare the max/min z value
The obvious downside of this method is it only works if the box is rotated in the z-axis, a rotation in x, y axis will give incorrect results - not a general solution to the problem but good enough for the particular problem I encountered in my project. I proceed to implement the method into my code and it works like a charm, then I happily close my project and went out and grab something to eat for lunch. XD
I hope you enjoy this week's update, feel free to provide an even easier solution for people that are not good at math (such as me) to give them a better time to develop their games!
Have a relaxing weekend! d(゚∀゚*)
Get 《Drifting : Weight of Feathers》
《Drifting : Weight of Feathers》
3rd-person action, fluid animation, versatile movement
Status | In development |
Author | rit2040 |
Genre | Action, Shooter |
Tags | 3D, Fast-Paced, Female Protagonist, Parkour, Singleplayer, Third-Person Shooter, ue4, Unreal Engine |
Languages | English |
More posts
- 《Drifting : Weight of Feathers》 Demo Ver 2.9 Now Available!Oct 09, 2021
- New Game Trailer and Dev Live Streaming Coming Soon!Sep 25, 2021
- 《Drifting : Weight of Feathers》 Demo 2.8 Update - New Hairstyle 'Youthful' a...Sep 04, 2021
- 《Drifting : Weight of Feathers》 Demo 2.7 Update - Gamepad Support and Online...Aug 02, 2021
- 《Drifting : Weight of Feathers》 Major Tutorial Overhaul in Ver2.6 UpdateJul 04, 2021
- 《Drifting : Weight of Feathers》 Opening Cinematic - Target EliminatedMay 22, 2021
- 《Drifting : Weight of Feathers》 Demo Ver. 2.1 Major Update!Mar 20, 2021
- 《Drifting : Weight of Feathers》 Played by ArrowSan1999 - A soothing voice an...Feb 07, 2021
- 《飄移 : 羽毛的重量》 2021 台北國際電玩展 新聞資料袋Jan 12, 2021
- 《Drifting : Weight of Feathers》 TpGS 2021 Press KitJan 12, 2021
Leave a comment
Log in with itch.io to leave a comment.