This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## CC0 license use this function wherever you want no need to credit. | |
## Call this function on any node to apply the weapon_clip_and_fov_shader.gdshader to all meshes within it. | |
func apply_clip_and_fov_shader_to_view_model(node3d : Node3D, fov_or_negative_for_unchanged = -1.0): | |
var all_mesh_instances = node3d.find_children("*", "MeshInstance3D") | |
if node3d is MeshInstance3D: | |
all_mesh_instances.push_back(node3d) | |
for mesh_instance in all_mesh_instances: | |
var mesh = mesh_instance.mesh | |
# Important to turn shadow casting off for view model or will cause issues with both | |
# view model, casting shadows on itself once unclipped, & also will look weird casting on world. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CC0/public domain/use for whatever you want no need to credit | |
# Call this function directly before move_and_slide() on your CharacterBody3D script | |
func _push_away_rigid_bodies(): | |
for i in get_slide_collision_count(): | |
var c := get_slide_collision(i) | |
if c.get_collider() is RigidBody3D: | |
var push_dir = -c.get_normal() | |
# How much velocity the object needs to increase to match player velocity in the push direction | |
var velocity_diff_in_push_dir = self.velocity.dot(push_dir) - c.get_collider().linear_velocity.dot(push_dir) | |
# Only count velocity towards push dir, away from character |