This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So what I want to do is to move a node2d's position up and down couple of pixels constantly at intervals to create a jittering effect. What I have so far is a function "onMove" that gets called every 1 second. Or is there any other way of achieving this effect?

  func _ready():
        var viewport = get_viewport().get_rect().size
        x = viewport.x
        y = viewport.y

        var timer =
        timer.connect("timeout", self, "onMove")

        #Sets frame updates

        #Sets UI

        #Set inputs 

    func onMove():
in Engine by (60 points)
edited by

1 Answer

0 votes
Best answer

Thats one way to do it, there are always different ways to do things. Others that come to my mind:

  • use an animation player
  • use a sin() function to offset the translation, you can use clamp() to make it more jittery and less smooth
by (290 points)
selected by

Thank you! I've went with the animation player. So much cleaner.

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 Frequently asked questions and 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 [email protected] with your username.