Click on '[Expand]' to view the code for a script.
This script renders a video to a new material on the object this script is attached to.
extends MeshInstance var stream = preload("video.ogv") func _ready(): var player = VideoPlayer.new() player.set_stream(stream) add_child(player) var texture = player.get_video_texture() material.albedo_texture = texture material.set_flag(material.FLAG_UNSHADED, true) set_material_override(material) player.play()
"video.ogv"with the path to your file. For me it is
"res://videos/test5.ogv". You can also use relative paths.
MeshInstancecan be replaced with whatever object you have this attached to.
MeshInstanceis the default for new mesh nodes.
And here's a version with looping video :) (and tabs ;))
extends MeshInstance var stream = preload("video.ogv") var player = VideoPlayer.new() func _ready(): player.set_stream(stream) add_child(player) var texture = player.get_video_texture() var material = SpatialMaterial.new() material.albedo_texture = texture material.set_flag(material.FLAG_UNSHADED, true) set_material_override(material) func _physics_process(_delta): if not player.is_playing(): player.play()
- Note that the variable declaration
var player = VideoPlayer.new()moves outside the
_readyfunction so that it can be used elsewhere.
deltais a trick to stop it reporting an error for not being referenced inside that function.
Reading and Writing Files
For example reading config files, and saving and loading games.
- How to Mix Sound & Background Music in Godot - May 2020 video.
- GETTING STARTED IN GODOT GAME ENGINE - EASY BEGINNER TUTORIAL - December 2016 Video.
- A Closer Look at the Godot Game Engine - Text, but video versions are availible if you prefer.
- Basic 3D Game in Godot 3 - Tutorial Part 1 - Video.
- Godot Vehicle Tutorial part 1 - import and setup a car - Video covering both Blender and Godot.
- Godot Recipes - Guide that's part of Kids Can Code. Doesn't actually feel well targeted at anyone I would consider a kid, but I personally find it useful! — rjt (talk)
- Ivan Skodje's Youtube channel has Godot tutorials related to making full games and scripting.
- Python - Free Python coarse on Code Academy.