0 votes

So i'd like to know how long does my raycast intersect a body.
I'm trying to make a cs:go like bullet penetration system for my project.

enter image description here

My Current Code: (goes through all the objects on the way one by one)

func shoot(damage:int=30) -> void:
    clear_exceptions()

    while is_colliding():                #Loop till no colliders
        force_raycast_update()           #Update raycast with updated expections
        var collider = get_collider()    #Get current colliding body
        add_exception(collider)          #Add the hit collider to expections

        if collider.is_in_group("damagable"):
            collider.health -= damage    #If target can be damaged, damage it

        #############################
        #ADD DAMAGE PENETRATION HERE#
        #############################

        if damage <= 0:                   #If the ray doesn't have any damage anymore, break the loop
            break

    print(damage)
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories