Godot Version
4.3 stable
Question
i tried to make an fps and wanted to add bulletholes when you shoot, the bulletholes are circles, but if you shoot, the bulletholes are stretched and bigger, and i want them to be at its original size, also the bullethole is exact at the same position as the wall/ground wich can make some weird texture visuals
func fire() -> void:
# While firing, apply continuous shake
shake_intensity = 0.5 # Full intensity shake during fire
# Apply shake (rotation)
camera.rotation = lerp(camera.rotation, Vector3(
randf_range(MAX_CAMERA_SHAKE * shake_intensity, -MAX_CAMERA_SHAKE * shake_intensity),
randf_range(MAX_CAMERA_SHAKE * shake_intensity, -MAX_CAMERA_SHAKE * shake_intensity),
0), 0.5)
# Handle shooter collision and damage
if shooter.is_colliding():
var target = shooter.get_collider()
if target:
#target.health -= gun_damage
create_bullet_hole()
func create_bullet_hole() -> void:
var bulletHoleNode = BULLET_HOLE.instantiate()
shooter.get_collider().add_child(bulletHoleNode)
bulletHoleNode.global_position = shooter.get_collision_point()
bulletHoleNode.look_at(bulletHoleNode.global_position + shooter.get_collision_normal(), Vector3.UP)
btw here are some images so you know what i mean
You are adding the bullet hole as a child of the collider, it seems like your collider (the wall) has been scaled, so it’s children are scaled too. You could add the bullet hole as a child of the tree root, the current_scene, or as a sibling of the collider if you think that will not be scaled.
get_tree().root.add_child(bulletHoleNode)
get_tree().current_scene.add_child(bulletHoleNode)
shooter.get_collider().add_sibling(bulletHoleNode)
Thanks for adding images, though you could’ve posted these as a reply to your first topic and it would bump the topic all the way to the top, a forum-friendly practice instead of making new topics.
THX, i added them as a child of a node3D calles “BulletHoles” but there are still problems, because the bullethole is exact at the same position as the face from the wall, it has some weird texture visuals, btw the visual effect is called “z-fighting”
also they dont rotate on the floor, so it will look weird
you can’t see it so clearly in the image but they are in the same degree as in the wall
after 2 days of trying, i solved it! for thoose who are wondering:
to fix the random scaling, i made the bullethole a child of a node3D that will contain all bulletholes and not just being a child of the collider, because if it was a child of the collider and the collider is scaled: you will get stretched/scwuished bulletholes( shoutout to @gertkeno )
var bulletHoleNode = BULLET_HOLE.instantiate()
bulletholes.add_child(bulletHoleNode)
to fix, z-fighting, i just changed the bullethole’s position to x:0, y:0, z: -0.001
and to fix the rotation issues, i made a surface detector for if its the ground, that the z axis rotates at 90°
func create_bullet_hole() -> void:
var bulletHoleNode = BULLET_HOLE.instantiate()
bulletholes.add_child(bulletHoleNode)
# Set the position of the bullet hole at the collision point
bulletHoleNode.global_position = shooter.get_collision_point()
# Get the normal of the surface
var normal = shooter.get_collision_normal()
# Determine rotation based on the normal
if abs(normal.y) > 0.5: # If the normal is mostly vertical (top/bottom)
bulletHoleNode.rotation_degrees = Vector3(90, 0, 0) # Rotate 90° on X-axis
else: # Otherwise, assume it's a wall face
bulletHoleNode.look_at(bulletHoleNode.global_position + normal, Vector3.UP)