0 votes

I try to do some flickering camp fire.
The light itself is somewhat changing the energy.
To make it more realistic I want some moving shadows on top.
So what I want is some slightly moving light source around the parent position.
What I have is a constantly (somewhat random) translating and moving away light source.

extends Spatial
func _ready():
func _process(_delta):
    $light.light_energy = .5 + randf()*.5+.5

Thanks for any advice

PS: using Godot 3.2.1

in Engine by (15 points)
recategorized by

1 Answer

+1 vote
Best answer

Store the random Vector3 as a variable and lerp to it.

var target : Vector3

func _ready():
    while true:
        target = Vector3(randf()*11+1, randf()*11+1, randf()*11+1)

func _process(delta):
    $light.translation = lerp($light.translation, target, delta*2)
by (3,227 points)
selected by

Ah thanks that helped I needed to change the target value not only in _ready() and then it worked.

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.