isometric cam

This commit is contained in:
2026-05-25 20:22:43 +03:00
parent 174b14fa61
commit 85b9c86164
3 changed files with 35 additions and 27 deletions
+3 -16
View File
@@ -1,12 +1,9 @@
[gd_scene format=3 uid="uid://crtm0xtiql3r8"]
[ext_resource type="Script" uid="uid://bn777gguclud5" path="res://player.gd" id="1_xhfnw"]
[ext_resource type="Script" uid="uid://b4td4k8yo5y78" path="res://camera_spring_arm.gd" id="2_kpjcp"]
[ext_resource type="Script" path="res://camera_iso.gd" id="2_camera_iso"]
[ext_resource type="PackedScene" uid="uid://qy6qrxdfgx2g" path="res://Assets/bull_v10.fbx" id="4_e80uo"]
[sub_resource type="SphereShape3D" id="SphereShape3D_kne1u"]
radius = 0.5
[sub_resource type="SphereShape3D" id="SphereShape3D_chest"]
radius = 0.35
@@ -32,18 +29,8 @@ shape = SubResource("SphereShape3D_belly")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.505, 0.4)
shape = SubResource("SphereShape3D_hips")
[node name="SpringArmPivot" type="Node3D" parent="." unique_id=1671817680]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.22, 0)
script = ExtResource("2_kpjcp")
[node name="SpringArm3D" type="SpringArm3D" parent="SpringArmPivot" unique_id=141439848]
collision_mask = 3
shape = SubResource("SphereShape3D_kne1u")
spring_length = 7.0
margin = 0.5
[node name="Camera3D" type="Camera3D" parent="SpringArmPivot/SpringArm3D" unique_id=1120161087]
keep_aspect = 0
[node name="Camera3D" type="Camera3D" parent="." unique_id=1120161087]
script = ExtResource("2_camera_iso")
[node name="bull_v10" parent="." unique_id=1386495166 instance=ExtResource("4_e80uo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.655, 0.23)
+22
View File
@@ -0,0 +1,22 @@
extends Camera3D
@export var height: float = 18.0
@export var horizontal_distance: float = 18.0
@export var horizontal_angle_deg: float = 45.0
@export var ortho_size: float = 15.0
func _ready() -> void:
set_as_top_level(true)
projection = PROJECTION_ORTHOGONAL
size = ortho_size
func _process(_delta: float) -> void:
var angle_rad := deg_to_rad(horizontal_angle_deg)
var offset := Vector3(
sin(angle_rad) * horizontal_distance,
height,
cos(angle_rad) * horizontal_distance,
)
var target := get_parent() as Node3D
global_position = target.global_position + offset
look_at(target.global_position, Vector3.UP)
+10 -11
View File
@@ -8,7 +8,7 @@ const HOOF_OFFSETS: Array = [
Vector3( 0.30, -0.25, 0.60),
]
@onready var camera_pivot: Node3D = $SpringArmPivot
@onready var camera_pivot: Node3D = $Camera3D
@onready var cube_guy: Node3D = $bull_v10
var _hoof_emitters: Array[CPUParticles3D] = []
@@ -177,18 +177,17 @@ func _physics_process(delta: float) -> void:
var charging := Input.is_action_pressed(&"charge")
var on_floor := is_on_floor()
# ── Left / right click thrust (only when mouse is captured) ─────────────
# ── Left / right click thrust ─────────────────────────────────────────────
# Left click → thrust NE (forward-right diagonal)
# Right click → thrust NW (forward-left diagonal)
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if Input.is_action_just_pressed(&"thrust_left") or Input.is_action_just_pressed(&"thrust_right"):
var raw := cube_guy.global_transform.basis.z
var bull_fwd := Vector3(raw.x, 0.0, raw.z).normalized()
var bull_right := bull_fwd.cross(Vector3.UP)
if Input.is_action_just_pressed(&"thrust_left"):
_apply_thrust((bull_fwd + bull_right).normalized())
else:
_apply_thrust((bull_fwd - bull_right).normalized())
if Input.is_action_just_pressed(&"thrust_left") or Input.is_action_just_pressed(&"thrust_right"):
var raw := cube_guy.global_transform.basis.z
var bull_fwd := Vector3(raw.x, 0.0, raw.z).normalized()
var bull_right := bull_fwd.cross(Vector3.UP)
if Input.is_action_just_pressed(&"thrust_left"):
_apply_thrust((bull_fwd + bull_right).normalized())
else:
_apply_thrust((bull_fwd - bull_right).normalized())
# Reset kick timer on landing so the first kick after a bounce is immediate
if on_floor and not _was_on_floor and direction: