Make several AnimationPlayer instances work separately

GridGrid Posts: 9Member
in 3D

Hello. Currently, when I play a single animation in AnimationPlayer, this animation starts playing in other instances.
Can I separate those somehow? Example.

Comments

  • GridGrid Posts: 9Member

    UPD: I replaced animations with shaders for now.
    My plan was to make effects like in this video.
    Right now it feels like a good solution. (Video).

    (Smoothstep example here imitates a line in a video, white noise there makes glow more interesting; I also enabled "glow" filter in camera options.)

    Code for a ShaderMaterial:

    shader_type spatial;
    render_mode cull_disabled;
    
    float rnd (vec2 st) {
        return fract(
            sin(
                dot(st.xy,
                vec2(12.9898,78.233))
            ) * 43758.5453123
        );
    }
    
    void fragment() {
        vec2 ipos = ceil(UV * 40.0);
        float d = 0.0;
        d += smoothstep(
            .05,
            .005,
            abs(sin(TIME)) - UV.y
        );
        d *= rnd(ipos + TIME);
        ALBEDO = vec3(d);
        ALPHA = d;
        EMISSION = vec3(d) * 6.0;
    }
    

    Still, it will be very nice to know how to do animations, which are independent from each other.

  • GridGrid Posts: 9Member

    UPD 2: I finally figured out what was wrong.

    Animations change material parameters, i.e. while animation is played for a single time, it changes each material's parameter. The solution was to duplicate CSGMesh instance material like that:

    extends CSGMesh
    
    func _init():
        var dup_mat = self.material.duplicate()
        self.material = dup_mat
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file