Created
February 28, 2018 10:15
-
-
Save tollyx/9b6fc075ce1033a69c93c18866ac13ca to your computer and use it in GitHub Desktop.
Godot hpysics-process tweening script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.