Guide:Godot: Difference between revisions

From Game Making Tools Wiki
(Added some scripting-specific tutorials)
m (Fixed the syntac for the Tutorial links)
Line 55: Line 55:


=== 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.


== See Also ==
== See Also ==
* [[Godot|Godot]]
* [[Godot]]

Revision as of 16:08, 13 August 2017

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()

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