The article is relevant to my last post, Godot: Texture, Grid Map, Move And Rotate.
I want to create a 3D game by Godot, here are some notes about it.
All files in the project are uploaded to GitHub: https://github.com/theArcticOcean/SimpleTools/tree/master/godotGame/NumberGameIn3D

Add Music And Play

Create a new node container to manage all audio streams.
Add an AudioStreamPlayer3D child node, load ogg file for its Stream. Adjust the parameters Unit Size and Max Db to get a better sound effect.

Add a test key and play our audio by it.

add key

Add playing code.

func _physics_process( delta ):
     if Input.is_action_pressed("test_key"):
        var player:AudioStreamPlayer3D = musicContainer.get_node( "explose" ).d
uplicate()
        player.stream = player.stream.duplicate()
        player.stream.loop = false
        player.global_transform.origin = $player/Camera.global_transform.origin
         player.play()
        $"/root".add_child( player )

Put Camera’s View To A Mesh’s Surface

Create a MeshInstance and generate a cube as mesh object. Add Viewport and its child node, the new Viewport object has its child node which is a Camera object.
We mark the flag Current of the camera true to use the camera in the ancestor viewport.

Then we need to create a shader material for our wall. Material – Create ShaderMaterial – click shader and edit, add the following code for the it.

shader_type spatial;
render_mode unshaded;

uniform sampler2D refl_tx;
void fragment(){
    ALBEDO = texture( refl_tx, vec2(1.0 - SCREEN_UV.x, SCREEN_UV.y) ).rgb;
}

Finally, make sure the resource local to scene and create a new viewport texture which connects child node Viewport for Refl tx.

Categories: Godot

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

XML To JSON
: Input your strings, the tool can convert XML to JSON for you.

X
0
Would love your thoughts, please comment.x
()
x