Godot Version
4.0
Question
I followed Chaff games tutorial on weapon manager with lukky’s ultimate fps controller. The marker3D node which is spawn point for bullets doesn’t rotate, remaining on positive Z axis even if I rotate it manually in player scene. Please help.
Ray Cast collision code:
func Get_Camera_Collision() → Vector3: var camera = get_viewport().get_camera_3d() var viewport = get_viewport().get_size()
var Ray_Origin = camera.project_ray_origin(viewport / 2)
var Ray_End = Ray_Origin + camera.project_local_ray_normal(viewport / 2) * Current_Weapon.Weapon_Range
var New_Intersection = PhysicsRayQueryParameters3D.create(Ray_Origin, Ray_End)
New_Intersection.set_exclude(collision_exculsion)
var Intersection = get_world_3d().direct_space_state.intersect_ray(New_Intersection)
if not Intersection.is_empty():
var Col_Point = Intersection.position
return Col_Point
else:
return Ray_End
Hit scan direction code:
func Hit_Scan_Collision(Collision_Point): var Bullet_Direction = (Collision_Point - bullet_point.get_global_transform().origin).normalized() var New_Intersection = PhysicsRayQueryParameters3D.create(bullet_point.get_global_transform().origin, Collision_Point + Bullet_Direction * 2)