#i want the fire trail to be... less constant

26 messages · Page 1 of 1 (latest)

manic ivy
#

func setfire(position: Vector2) -> void:
get_parent().add_child(trilha)
if $firestate.flip_h == false:
trilha.global_position = position + Vector2(-5,10)
else:
trilha.global_position = position + Vector2(10,10)

next lance
#

what's passed in as position?

manic ivy
next lance
# manic ivy setfire($firestate.global_position- Vector2(7,7) )

I'd try to see if you can do all of the above without using global_position - try using local positions only, it should be easier to position it from the origin
you might need to still use $firestate.global_position if the add_child isn't being added to the $firestate object

if there's still any offset issues, you should be able to figure out why by tweaking the values in your Vector2 adjustments

manic ivy
#

is hard using local position because this fire is a summon(child) of the slime(main character node)

#

if im understand what you saying

next lance
#

that way it's offset from the summoned character's position always, which will give you more control on where it spawns and how it offsets over time

manic ivy
#

extends KinematicBody2D

export var speed = 300
var velocity = Vector2(0, 0)
var click_positionF = Vector2(0, 0)
var target_positionF = Vector2(0,0)
var dela = Vector2(15,15)
var trilhaarq = preload("res://firetrail.tscn")
var trilha: Area2D
var total_delta
var cooldown = true

func _ready():

click_positionF = Vector2(position.x, position.y)

func _physics_process(delta):
var target_positionF = (click_positionF - position).normalized()
$firestate.flip_h = target_positionF.x < 0
trilha = trilhaarq.instance()

if Input.is_action_pressed("left_click") && Input.is_action_pressed("q"):
    click_positionF = get_global_mouse_position()

if position.distance_to(click_positionF) > 3 && $firestate.global_position.x > 0:
    move_and_slide(target_positionF * speed)
    $firestate.play("run")
    if cooldown == true:
        setfire($firestate.global_position- Vector2(7,7) ) 

        
        
else:
    $firestate.play("idle")

func setfire(position: Vector2) -> void:
get_parent().add_child(trilha)
if $firestate.flip_h == false:
trilha.global_position = position + Vector2(-5,10)
else:
trilha.global_position = position + Vector2(10,10)

#

this is the fire summon whole script (not the slime)

next lance
#

the way you're doing it is fine too btw, with the global position, but it can get kinda confusing when you start adding/subtracting offsets in that method (which is probably what's giving you trouble)

manic ivy
#

i was trying doing a timer on the fire trail but it look worse

#

the trail is an area 2d btw

#

the only code in the trail is the queu free

next lance
# manic ivy i was trying doing a timer on the fire trail but it look worse

there's a bit of a trick you can use on the delta if you want, that I use sometimes instead of timers

if delta % 10 == 0:
  <do your spawning code here>

if you aren't familiar with the "%" operation it's just a modulo, which means it gets the remainder after dividing by the number on the right side
so this only spawns the fire if the delta (the total number of ticks the script has been running) is evenly divided by 10

in other words, every 10 ticks of the physics process (you change the 10 to whatever you want, higher will mean more time between spawns)

#

(this is unrelated to your positioning issue though - you'll still want to play with the offsets to see if you can come up with a solution there)

manic ivy
#

if $firetrail.body_shape_entered($firetrail) == true:
queue_free()

#

would this work @next lance ?

next lance
manic ivy
#

the fire trail but i discover this is not a bolean

#

now im trying overlaps_area

#

its also not working

#

i want to check if the firetrail is overlaping to destroy it

next lance
# manic ivy i want to check if the firetrail is overlaping to destroy it

you'd need to compare it between instances of each fire trail object that's spawned, so on whatever object is actually creating them (I think the slime character, in your case? I'm not sure)
so whenever you create it, you'd need to handle that somehow. it's a little complicated, you'll want to check out a tutorial for signals if you haven't yet - you'll probably need them