isometric - Godot 3.0 沿路径更改 KinimaticBody 2D 的动画
问题描述
我试图让一个运动体将其动画更改为适当的等距动画,因为它遵循一条路径。我正在使用的代码如下,它附加到 A KinematicBody2D。任何想法都会有帮助,甚至改变结构等。
Game
--TileMap
----Pathe2D
------PatheFollow2D
--------KinematicBody2D
--------CollisionShape2D
--------AnimationSprite
目前的守则
extends KinematicBody2D
var direction = Vector2()
var currentdirection = Vector2(0,0)
# Called when the node enters the scene tree for the first time.
func _ready():
set_physics_process(true)
func _physics_process(delta):
var dir = position
var direction = dir.normalized()
print(position)
ghost_anim(dir)
# Moves Ghost
get_parent().set_offset(get_parent().get_offset() + 250 * delta)
func ghost_anim(direction):
var spritedir
if currentdirection != direction:
if currentdirection == Vector2(-1,-1):
spritedir = "Back_Left"
elif currentdirection == Vector2(1,-1):
spritedir = "Back_Right"
elif direction == Vector2(-1,1):
spritedir = "Front_Left"
elif direction == Vector2(1,1):
spritedir = "Front_Right"
else:
pass
else:
spritedir = "Front_Left"
get_node("Ghost").set_animation(spritedir)
currentdirection = direction
return currentdirection
解决方案
推荐阅读
- apache-spark - 在 pyspark 中分解 Maptype 列
- thingworx - 如何将视频发布到 Thingworx 平台
- visual-studio - Selenium 执行 SendKeys(Key.Enter) 时 Chrome 崩溃
- django - 防止在 SerializerMethodField 中重复查询
- angular6 - Angular 6无法读取未定义的属性'getScroll'
- python - Sklearn TfIdfVectorizer 删除包含所有停用词的文档
- javascript - 在输入字段内映射数据时模拟按键
- java - 正则表达式检查文件是否没有扩展名
- docker - 运行 tensorboard 以可视化 docker 容器在 Ray Rllib 中运行强化学习
- jekyll - 如何在帖子标题中添加换行符?