如何创建一个脚本,在该脚本中,当您按键时,例如“ E”,射击足球。如果对您来说并不困难,您可以写如何使腿上抬起腿的动画吗?)
Vector3不起作用。(
teTect键按(“ e”) - 使用UserInputService触发操作。 检查接近 - 在允许踢之前,请确保球员在球附近。 施加力 - 使用物理(如体速度)推动球。 播放动画 - 触发现实主义的踢动画。
您需要使用UserInputService。首先在启动游戏中创建一个Localscript,该内容在Explorer可见的启动器文件夹中。并键入此
local UserInputService = game.UserInputService
function Press()
if UserInputService.KeyCode = Enum.KeyCode.E then
—type in the things you want it to do after clicking E
end
end
UserInputService.InputBegin:Connect(Press)