Skip to content

Instantly share code, notes, and snippets.

@tollyx
Created February 28, 2018 10:15
Show Gist options
  • Save tollyx/9b6fc075ce1033a69c93c18866ac13ca to your computer and use it in GitHub Desktop.
Save tollyx/9b6fc075ce1033a69c93c18866ac13ca to your computer and use it in GitHub Desktop.
Godot hpysics-process tweening script
extends Spatial
var curr_frame_global = Transform()
var prev_frame = Transform()
var time_spent = 0
onready var time_duration = get_physics_process_delta_time()
func _enter_tree():
transform = Transform()
curr_frame_global = global_transform
func _process(delta):
if not visible: return
time_spent += delta
var progress = time_spent/time_duration
transform = prev_frame.interpolate_with(Transform(), progress)
curr_frame_global = global_transform
func _physics_process(delta):
time_spent = 0
time_duration = delta
global_transform = curr_frame_global
prev_frame = transform
@tollyx
Copy link
Author

tollyx commented Feb 28, 2018

Known issue: Tweened nodes freak out if your fps drops below the amount of physics steps.

Also feature that isn't implemented yet: Be able to increase the amount of frames that are being tweened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment