Guide:Godot: Difference between revisions

From Game Making Tools Wiki
(→‎Scripts: Note on clicking [expand])
(shader tut vid)
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
This script renders a video to a new material on the object this script is attached to.
This script renders a video to a new material on the object this script is attached to.
<div class="mw-collapsible-content">
<div class="mw-collapsible-content">
Godot only supports the [[:Wikipedia:Theora|Theora video codec]], but you can use something like [[FFmpeg]] to convert whatever video you have.
Godot only supports the [[:Wikipedia:Theora|Theora]] and [[Wikipedia:WebM|WebM]] video codecs (unless you are a really advanced user), but you can use something like [[FFmpeg]] to convert whatever video you have.


Source: [https://godotengine.org/qa/16661/video-skydome-video-image-texture-project-video-sphere-mesh Video skydome for VR - video to image texture? Project video on sphere mesh?]
Source: [https://godotengine.org/qa/16661/video-skydome-video-image-texture-project-video-sphere-mesh Video skydome for VR - video to image texture? Project video on sphere mesh?]
Line 60: Line 60:
* https://godot.readthedocs.io/en/stable/learning/step_by_step/filesystem.html#doc-filesystem
* https://godot.readthedocs.io/en/stable/learning/step_by_step/filesystem.html#doc-filesystem
* https://godotdevelopers.org/forum/discussion/comment/20047/#Comment_20047
* https://godotdevelopers.org/forum/discussion/comment/20047/#Comment_20047
== Audio ==
* [https://www.youtube.com/watch?v=6VZnabKdlQ8 How to Mix Sound & Background Music in Godot] - May 2020 video.


== Tutorials ==
== Tutorials ==
* [https://www.youtube.com/watch?v=K5-5j4H4Ypo GETTING STARTED IN GODOT GAME ENGINE - EASY BEGINNER TUTORIAL] - Video.
* [https://www.youtube.com/watch?v=K5-5j4H4Ypo GETTING STARTED IN GODOT GAME ENGINE - EASY BEGINNER TUTORIAL] - December 2016 Video.
* [http://www.gamefromscratch.com/post/2015/01/04/A-Closer-Look-at-the-Godot-Game-Engine.aspx A Closer Look at the Godot Game Engine] - Text, but [http://www.gamefromscratch.com/page/Godot-Game-Engine-tutorial-series.aspx video versions are availible] if you prefer.
* [http://www.gamefromscratch.com/post/2015/01/04/A-Closer-Look-at-the-Godot-Game-Engine.aspx A Closer Look at the Godot Game Engine] - Text, but [http://www.gamefromscratch.com/page/Godot-Game-Engine-tutorial-series.aspx video versions are availible] if you prefer.
* [https://www.youtube.com/watch?v=-D-IcbsdT04 Basic 3D Game in Godot 3 - Tutorial Part 1] - Video.
* [https://www.youtube.com/watch?v=-D-IcbsdT04 Basic 3D Game in Godot 3 - Tutorial Part 1] - Video.
* [https://godottuts.miraheze.org/wiki/Main_Page GodotTuts] wiki.
* [https://www.youtube.com/watch?v=B5vE-nNszxA Godot Vehicle Tutorial part 1 - import and setup a car] - Video covering both [[Blender]] and [[Godot]].
* [https://www.youtube.com/watch?v=B5vE-nNszxA Godot Vehicle Tutorial part 1 - import and setup a car] - Video covering both [[Blender]] and [[Godot]].
* [http://kidscancode.org/godot_recipes/ 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! — [[User:Rjt|rjt]] ([[User talk:Rjt|talk]])


=== Scripting ===
=== Scripting ===
* [https://www.youtube.com/channel/UCBHuFCVtZ9vVPkL2VxVHU8A Ivan Skodje]'s Youtube channel has Godot tutorials related to making full games and scripting.
* [https://www.youtube.com/channel/UCBHuFCVtZ9vVPkL2VxVHU8A Ivan Skodje]'s Youtube channel has Godot tutorials related to making full games and scripting.
* [https://www.codecademy.com/learn/python Python] - Free Python coarse on Code Academy.
* [https://www.codecademy.com/learn/python Python] - Free Python coarse on Code Academy.
=== Shaders ===
* [https://www.youtube.com/watch?v=vm9Sdvhq6ho Godot 3D shader tutorial (1): Water in 3D]


== See Also ==
== See Also ==
* [[Godot]].
* [[Godot]].
* [https://github.com/godotengine/awesome-godot Awesome Godot] - List of links.
* [https://godot-engine.zeef.com/andre.antonio.schmitz Godot Engine] links on Zeef.
* [https://godot-engine.zeef.com/andre.antonio.schmitz Godot Engine] links on Zeef.
* [https://old.reddit.com/r/godot/search/?q=flair%3ATutorial&sort=new&restrict_sr=on Tutorials] on the Godot Reddit board.

Latest revision as of 19:06, 13 March 2021

Scripts

Click on '[Expand]' to view the code for a script.

video-to-texture.gd

This script renders a video to a new material on the object this script is attached to.

Godot only supports the Theora and WebM video codecs (unless you are a really advanced user), but you can use something like FFmpeg to convert whatever video you have.

Source: Video skydome for VR - video to image texture? Project video on sphere mesh?

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()
  • Replace "video.ogv" with the path to your file. For me it is "res://videos/test5.ogv". You can also use relative paths.
  • MeshInstance can be replaced with whatever object you have this attached to. MeshInstance is 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 _ready function so that it can be used elsewhere.
  • Using _delta instead of delta is 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.

Audio

Tutorials

Scripting

  • Ivan Skodje's Youtube channel has Godot tutorials related to making full games and scripting.
  • Python - Free Python coarse on Code Academy.

Shaders

See Also