Attention |
Topic was automatically imported from the old Question2Answer platform. | |

Asked By |
Genesis689 |

I’m making a left,right,back and forward jump animation for my player but when I play it in script it starts from the origin point instead of where the current position is. How do I change it so that I can start the animation from the kinematic body’s current position in game? Thank you

```
extends KinematicBody
```

export var speed = 14

export var fall_acceleration = 75

var key1_translate

var key2_translate

var key3_translate

var anim = $AnimationPlayer.get_animation(“jump”)

var velocity = Vector3.ZERO

func _physics_process(delta):

var direction = Vector3.ZERO

```
if Input.is_action_just_pressed("move_right"):
key1_translate = Vector3(translation.x,translation.y,translation.z)
key2_translate = Vector3(translation.x,(translation.y + 2),(translation.z + 2))
key3_translate = Vector3(translation.x,translation.y,(translation.z + 4))
$AnimationPlayer.play("jump")
if Input.is_action_just_pressed("move_left"):
key1_translate = Vector3(translation.x,translation.y,translation.z)
key2_translate = Vector3(translation.x,(translation.y - 2),(translation.z - 2))
key3_translate = Vector3(translation.x,translation.y,(translation.z - 4))
$AnimationPlayer.play("jump")
if Input.is_action_just_pressed("move_back"):
key1_translate = Vector3(translation.x,translation.y,translation.z)
key2_translate = Vector3((translation.x - 2),(translation.y - 2),translation.z)
key3_translate = Vector3((translation.x - 4),translation.y,translation.z)
$AnimationPlayer.play("jump")
if Input.is_action_just_pressed("move_forward"):
key1_translate = Vector3(translation.x,translation.y,translation.z)
key2_translate = Vector3((translation.x + 2),(translation.y + 2),translation.z)
key3_translate = Vector3((translation.x + 4),translation.y,translation.z)
$AnimationPlayer.play("jump")
```

I’ve put together this solution but I don’t understand how to change the individual keyframes on each track. My jump animations tracks are the kinematic body’s translation and another for its scale. I don’t need to change the scale but I need help on how to change the keyframe values for the translation track from the script. Any help?

Genesis689 | 2022-12-26 16:05

Its okay I read the doc and found it. It was

```
anim.track_set_key_value(0,0,key1_translate)
```

Genesis689 | 2022-12-26 16:37