Fix collision shape of sensor entity
This commit is contained in:
parent
2a1207c513
commit
f6d9828ad7
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1d0d7c19b4862ffa6c78a12151cbd01acb0f1f23400a7c75ad795680b61b6a1a
|
||||
size 301
|
||||
oid sha256:26d5c6e9529db2b628074d05b9764878eaf60f35c6042f82944c2f12065766df
|
||||
size 339
|
||||
|
|
|
@ -3,6 +3,7 @@ extends Entity
|
|||
const Entity = preload ("../entity.gd")
|
||||
|
||||
@onready var label: Label3D = $Label
|
||||
@onready var collision_shape = $CollisionShape3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
@ -25,3 +26,12 @@ func set_text(stateInfo):
|
|||
text += " " + stateInfo["attributes"]["unit_of_measurement"]
|
||||
|
||||
label.text = text
|
||||
|
||||
var font = label.get_font()
|
||||
var width = 0
|
||||
var height = 0
|
||||
|
||||
var size = font.get_multiline_string_size(text, HORIZONTAL_ALIGNMENT_CENTER, label.width, label.font_size)
|
||||
|
||||
collision_shape.shape.size.x = size.x * label.pixel_size * 0.5
|
||||
collision_shape.shape.size.y = size.y * label.pixel_size * 0.25
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://xsiy71rsqulj"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://xsiy71rsqulj"]
|
||||
|
||||
[ext_resource type="Script" path="res://content/entities/sensor/sensor.gd" id="1_57ac8"]
|
||||
[ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="2_4np3x"]
|
||||
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_fpq5q"]
|
||||
[ext_resource type="Script" path="res://content/functions/occludable.gd" id="3_l3sp5"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_r20gc"]
|
||||
radius = 0.1
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_phuot"]
|
||||
resource_local_to_scene = true
|
||||
size = Vector3(0.18, 0.03, 0.02)
|
||||
|
||||
[node name="Sensor" type="StaticBody3D" groups=["entity"]]
|
||||
collision_mask = 0
|
||||
script = ExtResource("1_57ac8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("SphereShape3D_r20gc")
|
||||
shape = SubResource("BoxShape3D_phuot")
|
||||
|
||||
[node name="Label" type="Label3D" parent="."]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0)
|
||||
pixel_size = 0.001
|
||||
text = "some text
|
||||
"
|
||||
font = ExtResource("2_4np3x")
|
||||
font_size = 80
|
||||
|
||||
[node name="Movable" type="Node" parent="."]
|
||||
|
|
Loading…
Reference in New Issue
Block a user