Browse Source

Revert "Remove ray and use Camera.project_position("

This reverts commit f41676c672.

I misunderstood the way the camera projections work, and I'm better off
using the original raycasting strategy.
master
Luna 7 years ago
parent
commit
2aac9d9a1a
2 changed files with 12 additions and 4 deletions
  1. +9
    -1
      scenes/player.tscn
  2. +3
    -3
      scripts/heroes/1.gd

+ 9
- 1
scenes/player.tscn View File

@ -20,7 +20,7 @@ radial_segments = 64
rings = 8 rings = 8
_sections_unfolded = [ "Resource" ] _sections_unfolded = [ "Resource" ]
[node name="RigidBody" type="RigidBody" groups=[
[node name="RigidBody" type="RigidBody" index="0" groups=[
"player", "player",
]] ]]
@ -98,6 +98,14 @@ near = 0.05
far = 100.0 far = 100.0
_sections_unfolded = [ "Transform", "Visibility" ] _sections_unfolded = [ "Transform", "Visibility" ]
[node name="Ray" type="RayCast" parent="Yaw/Pitch" index="1"]
enabled = true
exclude_parent = true
cast_to = Vector3( 0, 0, -100 )
collision_mask = 1
_sections_unfolded = [ "Transform" ]
[node name="MeshInstance" type="MeshInstance" parent="." index="4"] [node name="MeshInstance" type="MeshInstance" parent="." index="4"]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.95, 0 ) transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.95, 0 )


+ 3
- 3
scripts/heroes/1.gd View File

@ -23,10 +23,10 @@ func _process(delta):
if is_placing_wall: if is_placing_wall:
# Find the point we're looking at, and put the wall there # Find the point we're looking at, and put the wall there
var aim = get_node("Yaw/Pitch").get_global_transform().basis var aim = get_node("Yaw/Pitch").get_global_transform().basis
var camera = get_node("Yaw/Pitch/Camera")
var pos = camera.project_position(Vector2())
var look_ray = get_node("Yaw/Pitch/Ray")
var pos = look_ray.get_collision_point()
placing_wall_node.set_translation(pos) placing_wall_node.set_translation(pos)
var towards = camera.project_ray_normal(Vector2()) + pos
var towards = look_ray.get_collision_normal() + pos
var up = -aim[2] # Wall should be horizontal to my view var up = -aim[2] # Wall should be horizontal to my view
placing_wall_node.look_at(towards, up) placing_wall_node.look_at(towards, up)


Loading…
Cancel
Save