Guide:Godot: Difference between revisions

From Game Making Tools Wiki
(→‎Tutorials: Added a new tutorial)
(Added some links, and made video script collapsable (and starts collapsed))
Line 1: Line 1:
== Scripts ==
== Scripts ==
=== video-to-texture.gd ===
=== video-to-texture.gd ===
<div class="mw-collapsible mw-collapsed">
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">
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 video codec]], but you can use something like [[FFmpeg]] to convert whatever video you have.


Line 49: Line 50:
player.play()
player.play()
</pre>
</pre>
</div></div>


== Reading and Writing Files ==
== Reading and Writing Files ==
Line 55: Line 57:
* 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


== Tutorials ==
== Tutorials ==
Line 61: Line 62:
* [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.


=== Scripting ===
=== Scripting ===
Line 67: Line 69:


== See Also ==
== See Also ==
* [[Godot]]
* [[Godot]].
* [https://godot-engine.zeef.com/andre.antonio.schmitz Godot Engine] links on Zeef.

Revision as of 11:16, 4 August 2018

Scripts

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 video codec, 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 TestCube

var stream = preload("video.ogv")

func _ready():
    var player = VideoPlayer.new()
    player.set_stream(stream)
    add_child(player)
    var texture = player.get_video_texture()
    var material = FixedMaterial.new()
    material.set_texture(FixedMaterial.PARAM_DIFFUSE, 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/test2.ogv". You can also use relative paths.
  • TestCube can be replaced with whatever object you have this attached to, I think?

And here's a version with looping video :) (and tabs ;))

extends TestCube

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 = FixedMaterial.new()
	material.set_texture(FixedMaterial.PARAM_DIFFUSE, texture)
	material.set_flag(Material.FLAG_UNSHADED, true)
	set_material_override(material)
	set_process(true)

func _process(delta):
	if not player.is_playing():
		player.play()

Reading and Writing Files

For example reading config files, and saving and loading games.

Tutorials

Scripting

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

See Also