generated from krampus/template-godot4
	Free camera & shot projection collide with water
This commit is contained in:
		
							parent
							
								
									30dc7050be
								
							
						
					
					
						commit
						7c3a2002b7
					
				| @ -230,7 +230,7 @@ locale/translations=PackedStringArray("res://assets/text/text.en.translation") | |||||||
| [layer_names] | [layer_names] | ||||||
| 
 | 
 | ||||||
| 3d_physics/layer_1="Collision Geometry" | 3d_physics/layer_1="Collision Geometry" | ||||||
| 3d_physics/layer_2="Layer 2" | 3d_physics/layer_2="Water" | ||||||
| 3d_physics/layer_27="Glass Material" | 3d_physics/layer_27="Glass Material" | ||||||
| 3d_physics/layer_28="Metal Material" | 3d_physics/layer_28="Metal Material" | ||||||
| 3d_physics/layer_29="Rock Material" | 3d_physics/layer_29="Rock Material" | ||||||
|  | |||||||
| @ -316,6 +316,7 @@ func _show_shot_projection() -> void: | |||||||
| 	if not game_ball: | 	if not game_ball: | ||||||
| 		return | 		return | ||||||
| 
 | 
 | ||||||
|  | 	shot_projection.set_ball(game_ball) | ||||||
| 	shot_projection.putt_projection = club_type == Club.Type.PUTTER | 	shot_projection.putt_projection = club_type == Club.Type.PUTTER | ||||||
| 	shot_projection.initial_speed = 1 | 	shot_projection.initial_speed = 1 | ||||||
| 	shot_projection.basis = Basis.from_euler(Vector3(club.angle, 0, 0)) | 	shot_projection.basis = Basis.from_euler(Vector3(club.angle, 0, 0)) | ||||||
| @ -324,7 +325,6 @@ func _show_shot_projection() -> void: | |||||||
| 	tween.tween_property(shot_projection, "initial_speed", shot_speed, CAMERA_SNAP_TIME).set_trans( | 	tween.tween_property(shot_projection, "initial_speed", shot_speed, CAMERA_SNAP_TIME).set_trans( | ||||||
| 		Tween.TRANS_QUAD | 		Tween.TRANS_QUAD | ||||||
| 	) | 	) | ||||||
| 	shot_projection.linear_damp = game_ball.linear_damp |  | ||||||
| 	shot_projection.show() | 	shot_projection.show() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -574,7 +574,7 @@ loop_animation = 1 | |||||||
| 
 | 
 | ||||||
| [node name="ShotProjection" parent="ArrowPivot" instance=ExtResource("4_ry2ho")] | [node name="ShotProjection" parent="ArrowPivot" instance=ExtResource("4_ry2ho")] | ||||||
| unique_name_in_owner = true | unique_name_in_owner = true | ||||||
| transform = Transform3D(1, 0, 0, 0, 0.707107, -0.707107, 0, 0.707107, 0.707107, 0, -0.02, 0) | transform = Transform3D(1, 0, 0, 0, 0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 0, 0) | ||||||
| visible = false | visible = false | ||||||
| initial_speed = 50.0 | initial_speed = 50.0 | ||||||
| time_step = 0.1 | time_step = 0.1 | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ const PUTT_ATTRITION := 0.8325  # green? | |||||||
| ## Uses continuous collision detection. | ## Uses continuous collision detection. | ||||||
| @export var check_collision := true | @export var check_collision := true | ||||||
| ## Mask for collision checking. | ## Mask for collision checking. | ||||||
| @export_flags_3d_physics var collision_mask := 1 | @export_flags_3d_physics var collision_mask := 1 | 2 | ||||||
| ## Bodies excluded from collision checking. | ## Bodies excluded from collision checking. | ||||||
| ## This should probably include the ball! | ## This should probably include the ball! | ||||||
| @export var excluded_bodies: Array[CollisionObject3D] = [] | @export var excluded_bodies: Array[CollisionObject3D] = [] | ||||||
| @ -61,6 +61,11 @@ var _cached_vel: Vector3 | |||||||
| @onready var debug_draw: Control = %DebugDraw | @onready var debug_draw: Control = %DebugDraw | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | func set_ball(ball: GameBall) -> void: | ||||||
|  | 	global_position = ball.global_position | ||||||
|  | 	linear_damp = ball.linear_damp | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| func _process(_delta: float) -> void: | func _process(_delta: float) -> void: | ||||||
| 	if not visible: | 	if not visible: | ||||||
| 		# Don't bother if we're not visible | 		# Don't bother if we're not visible | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
| [node name="FreeCamera" type="CharacterBody3D"] | [node name="FreeCamera" type="CharacterBody3D"] | ||||||
| process_mode = 3 | process_mode = 3 | ||||||
| collision_layer = 0 | collision_layer = 0 | ||||||
|  | collision_mask = 3 | ||||||
| script = ExtResource("1_3gm3q") | script = ExtResource("1_3gm3q") | ||||||
| 
 | 
 | ||||||
| [node name="CollisionShape3D" type="CollisionShape3D" parent="."] | [node name="CollisionShape3D" type="CollisionShape3D" parent="."] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user