So I know there’s been tutorials for oxygen bars when you go underwater but I have an ocean in my game which means that you can come up for air but the tutorials for oxygen bars when you come up for air the air level decreases and you have to jump fully out of the water to get air which obviously wouldn’t work for me. I was wondering if there was a way to get air just by popping your head out of the water kinda like in Minecraft
I’ve seen this question many times in DevForum. You tried to search for an answer?
The best way I found to do it, is by Reading Voxels on top of the Character’s Head.
You need to use
Terrain:WorldToCell
, Region3
and Terrain:ReadVoxels
Once you read the Voxels material over the head of the character, if its water, drain oxygen, if its air increase oxygen.
Took me many tests to achieve it, I tried raycasting and many weird creative ways to do it… But I found Reading Voxels works perfect.
I’m going to look into this, but in the meantime, is there a way I can get started on making a script to read voxels because I have little coding experience and I don’t even know what reading voxels are. I don’t need a whole script but I just want to know how I could make this work
Maybe check out this post on the dev hub.
Also be sure to check out how terrain works on the dev hub
I looked at that and I can’t find any videos or articles that kinda show how I can read voxels and the dev hub post is kinda confusing like I know im not just going to find a tutorial for exactly what I need but I was wondering if there were any resources or people that knew a little more about this than I do so I knew what to do to make this work
Do you mind showing me how you did this? I’ve been trying to get this to work and I can’t figure this out.