#issue with pathing for an attack.

2 messages · Page 1 of 1 (latest)

tired sail
#

signal remove_from_array(object)

var speed = 100.0  # Adjust for desired movement speed
var curve_amplitude = 50.0  # Adjust for curve strength
var curve_frequency = 2.0  # Adjust for curve tightness
var theta = 0.0  # Current angle for position on the curve
var initial_throw = true  # Flag to track initial throw phase
var initial_position: Vector2
var target: Vector2


func _ready():
    pass

func _physics_process(delta):
    var initial_pos = Globals.player_pos
    
    if initial_throw:
        
        # Update theta for outward movement
        theta += delta * speed  # Adjust speed for desired movement

        # Calculate position based on lemniscate equation
        var r = sqrt(sin(2 * theta)) * curve_amplitude
        var offset = Vector2(sin(theta) * r, cos(theta) * r)
        var current_position = initial_pos + offset
        position = current_position
        

        # Check if outward throw is complete (adjust distance based on your level design)
        if theta >= PI:
            initial_throw = false
            theta = PI  # Reset theta for return path

            
func _on_timer_timeout():
    emit_signal("remove_from_array", self)
    queue_free()
    

func _on_initial_spawn_timer_timeout():
    initial_throw = false
#

And this is the portion that is causing me issues ``` func _physics_process(delta):
var initial_pos = Globals.player_pos

if initial_throw:
    
    # Update theta for outward movement
    theta += delta * speed  # Adjust speed for desired movement

    # Calculate position based on lemniscate equation
    var r = sqrt(sin(2 * theta)) * curve_amplitude
    var offset = Vector2(sin(theta) * r, cos(theta) * r)
    var current_position = initial_pos + offset
    position = current_position
    

    # Check if outward throw is complete (adjust distance based on your level design)
    if theta >= PI:
        initial_throw = false
        theta = PI  # Reset theta for return path```