galo 1 year ago
parent
commit
2a98d1e8d1
3 changed files with 111 additions and 60 deletions
  1. 0 38
      Camera.gd
  2. 111 6
      Control.tscn
  3. 0 16
      VideoPlayer.gd

+ 0 - 38
Camera.gd

@@ -1,66 +1,28 @@
 extends Camera
-
 onready var Player = get_parent()
-
-## Increase this value to give a slower turn speed
 const CAMERA_TURN_SPEED = 200
 
 func _ready():
-	## Tell Godot that we want to handle input
 	set_process_input(true)
 	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
 	
 
 func look_updown_rotation(rotation = 0):
-	"""
-	Returns a new Vector3 which contains only the x direction
-	We'll use this vector to compute the final 3D rotation later
-	"""
 	var toReturn = self.get_rotation() + Vector3(rotation, 0, 0)
-
-	##
-	## We don't want the player to be able to bend over backwards
-	## neither to be able to look under their arse.
-	## Here we'll clamp the vertical look to 90° up and down
 	toReturn.x = clamp(toReturn.x, PI / -2, PI / 2)
-
 	return toReturn
 
 func look_leftright_rotation(rotation = 0):
-	"""
-	Returns a new Vector3 which contains only the y direction
-	We'll use this vector to compute the final 3D rotation later
-	"""
 	return Player.get_rotation() + Vector3(0, rotation, 0)
 
 func _input(event):
-	"""
-	First person camera controls
-	"""
-	##
-	## We'll only process mouse motion events
 	if not event is InputEventMouseMotion:
 		return
-
-	##
-	## We'll use the parent node "Player" to set our left-right rotation
-	## This prevents us from adding the x-rotation to the y-rotation
-	## which would result in a kind of flight-simulator camera
 	Player.set_rotation(look_leftright_rotation(event.relative.x / -CAMERA_TURN_SPEED))
-
-	##
-	## Now we can simply set our y-rotation for the camera, and let godot
-	## handle the transformation of both together
 	self.set_rotation(look_updown_rotation(event.relative.y / -CAMERA_TURN_SPEED))
 
 func _enter_tree():
-	"""
-	Hide the mouse when we start
-	"""
 	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
 
 func _leave_tree():
-	"""
-	Show the mouse when we leave
-	"""
 	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

+ 111 - 6
Control.tscn

@@ -1,4 +1,4 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
 
 [ext_resource path="res://31plan2202 [QIPRotw1_6c].ogv" type="VideoStream" id=1]
 [ext_resource path="res://Camera.gd" type="Script" id=2]
@@ -17,7 +17,7 @@ albedo_texture = SubResource( 1 )
 
 [sub_resource type="Animation" id=4]
 resource_name = "autostuff"
-length = 60.0
+length = 46.0
 loop = true
 step = 1.0
 tracks/0/type = "value"
@@ -58,6 +58,112 @@ tracks/2/keys = {
 "method": "stop"
 } ]
 }
+tracks/3/type = "method"
+tracks/3/path = NodePath("Spatial/Camera")
+tracks/3/interp = 1
+tracks/3/loop_wrap = true
+tracks/3/imported = false
+tracks/3/enabled = true
+tracks/3/keys = {
+"times": PoolRealArray( 40, 46 ),
+"transitions": PoolRealArray( 1, 1 ),
+"values": [ {
+"args": [  ],
+"method": "_leave_tree"
+}, {
+"args": [  ],
+"method": "_enter_tree"
+} ]
+}
+tracks/4/type = "method"
+tracks/4/path = NodePath("AnimationPlayer")
+tracks/4/interp = 1
+tracks/4/loop_wrap = true
+tracks/4/imported = false
+tracks/4/enabled = true
+tracks/4/keys = {
+"times": PoolRealArray( 46 ),
+"transitions": PoolRealArray( 1 ),
+"values": [ {
+"args": [ "autostuff2", -1, 1.0, false ],
+"method": "play"
+} ]
+}
+
+[sub_resource type="Animation" id=5]
+resource_name = "autostuff2"
+length = 46.0
+loop = true
+step = 1.0
+tracks/0/type = "value"
+tracks/0/path = NodePath("Button2:visible")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/keys = {
+"times": PoolRealArray( 0, 10, 16 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 1,
+"values": [ false, true, false ]
+}
+tracks/1/type = "value"
+tracks/1/path = NodePath("Button:visible")
+tracks/1/interp = 1
+tracks/1/loop_wrap = true
+tracks/1/imported = false
+tracks/1/enabled = true
+tracks/1/keys = {
+"times": PoolRealArray( 0, 10, 16 ),
+"transitions": PoolRealArray( 1, 1, 1 ),
+"update": 1,
+"values": [ false, true, false ]
+}
+tracks/2/type = "method"
+tracks/2/path = NodePath("Viewport/VideoPlayer")
+tracks/2/interp = 1
+tracks/2/loop_wrap = true
+tracks/2/imported = false
+tracks/2/enabled = false
+tracks/2/keys = {
+"times": PoolRealArray( 16 ),
+"transitions": PoolRealArray( 1 ),
+"values": [ {
+"args": [  ],
+"method": "stop"
+} ]
+}
+tracks/3/type = "method"
+tracks/3/path = NodePath("Spatial/Camera")
+tracks/3/interp = 1
+tracks/3/loop_wrap = true
+tracks/3/imported = false
+tracks/3/enabled = true
+tracks/3/keys = {
+"times": PoolRealArray( 10, 16 ),
+"transitions": PoolRealArray( 1, 1 ),
+"values": [ {
+"args": [  ],
+"method": "_leave_tree"
+}, {
+"args": [  ],
+"method": "_enter_tree"
+} ]
+}
+tracks/4/type = "method"
+tracks/4/path = NodePath("AnimationPlayer")
+tracks/4/interp = 1
+tracks/4/loop_wrap = true
+tracks/4/imported = false
+tracks/4/enabled = true
+tracks/4/keys = {
+"times": PoolRealArray( 16 ),
+"transitions": PoolRealArray( 1 ),
+"values": [ {
+"args": [ "autostuff2", -1, 1.0, false ],
+"method": "play"
+} ]
+}
 
 [node name="Control" type="Control"]
 anchor_right = 1.0
@@ -95,11 +201,8 @@ fov = 80.0
 far = 75.0
 script = ExtResource( 2 )
 
-[node name="RayCast" type="RayCast" parent="Spatial/Camera"]
-visible = false
-cast_to = Vector3( 0, 0, -100 )
-
 [node name="Button" type="Button" parent="."]
+visible = false
 margin_left = 494.642
 margin_top = 258.069
 margin_right = 608.642
@@ -110,6 +213,7 @@ __meta__ = {
 }
 
 [node name="Button2" type="Button" parent="."]
+visible = false
 margin_left = 361.0
 margin_top = 260.0
 margin_right = 472.0
@@ -122,6 +226,7 @@ __meta__ = {
 [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
 autoplay = "autostuff"
 anims/autostuff = SubResource( 4 )
+anims/autostuff2 = SubResource( 5 )
 [connection signal="button_down" from="Button" to="Viewport/VideoPlayer" method="_on_Button_button_down"]
 [connection signal="button_down" from="Button" to="Button2" method="hide"]
 [connection signal="button_down" from="Button" to="Button" method="hide"]

+ 0 - 16
VideoPlayer.gd

@@ -1,21 +1,5 @@
 extends VideoPlayer
 
-
-# Declare member variables here. Examples:
-# var a = 2
-# var b = "text"
-
-
-# Called when the node enters the scene tree for the first time.
-func _ready():
-	pass # Replace with function body.
-
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-#func _process(delta):
-#	pass
-
-
 func _on_Button_button_down():
 	stream = load('res://test.ogv')
 	play()