Implemented simple quest system
This commit is contained in:
27
proto3/godot/ui/quest_indicator.gd
Normal file
27
proto3/godot/ui/quest_indicator.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
var target: = Vector3()
|
||||
var rect: = Rect2()
|
||||
func _ready():
|
||||
var pos = get_viewport().get_camera().unproject_position(target)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
var pos = get_viewport().get_camera().unproject_position(target)
|
||||
rect = get_viewport_rect()
|
||||
if rect.has_point(pos):
|
||||
if !visible:
|
||||
show()
|
||||
else:
|
||||
pos.x = clamp(pos.x, rect.position.x, rect.position.x + rect.size.x)
|
||||
pos.y = clamp(pos.x, rect.position.x, rect.position.x + rect.size.x)
|
||||
position = position.linear_interpolate(pos, delta)
|
||||
|
||||
10
proto3/godot/ui/quest_indicator.tscn
Normal file
10
proto3/godot/ui/quest_indicator.tscn
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://ui/textures/minimapIcon_exclamationRed.png" type="Texture" id=1]
|
||||
[ext_resource path="res://ui/quest_indicator.gd" type="Script" id=2]
|
||||
|
||||
[node name="quest_indicator" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
Reference in New Issue
Block a user