0 votes

Hi, i have a 2d sprite that i made and i did try use it for after attack collisions.
-Attack reach the enemy, collision happens,
-2d sprite get instanced at the collision point.

this is my code: (at the bullet node with a raycast added)

if $attack_collision_point_raycast.is_colliding():
    collision_point = $attack_collision_point_raycast.get_collision_point()
    print(collision_point)
    var instance_collision_fire = preload ("res://sahneler/skills/basic_collision_fire.tscn").instance()
    add_child(instance_collision_fire)
    instance_collision_fire.global_translate(Vector3(collision_point.x,collision_point.y,collision_point.z))

sprite just blink and gone, and not at the collision point. i did try few things, but couldn't solve it in the end.

in Engine by (93 points)
edited by

1 Answer

0 votes
Best answer

well, bruh, solve it.

if $attack_collision_point_raycast.is_colliding():
    collision_point = $attack_collision_point_raycast.get_collision_point()
    print(collision_point)
    var instance_collision_fire = preload ("res://sahneler/skills/basic_collision_fire.tscn").instance()
    add_child(instance_collision_fire)
    instance_collision_fire.global_transform.origin.x = collision_point.x
    instance_collision_fire.global_transform.origin.y = 7 #because want to sprite instanced above the enemy, it is a top_down game, so this look nicer :)
    instance_collision_fire.global_transform.origin.z = collision_point.z

i feel stupid. :)

by (93 points)
edited by
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.