求助!!角色动画控制脚本希望加入其它按键~~

No replies
jinshutiegan
User offline. Last seen 46 周 4 天 ago. Offline
注册用户
Joined: 11/20/2009
Points: 10

求助!!角色动画控制脚本希望加入其它按键~~

.threadtags_tag {margin:0px !important;background:none !important;padding:12px 0 !important;color: #444 !important;} .threadtags_tag span {border:1px solid #E6E7E1; padding:10px 14px 10px 32px; background: url(http://images.5d6d.net/dz7/default/tag.gif) no-repeat 10px 50%;} .threadtags_tag a{color:#09C !important;}相关搜索: 脚本, 动画, 角色, 求助 本人是美工,程序基本一窍不通,从网上视频学写了一段第三人称角色动画的脚本。写完后能实现人物行走和跑步待机三项最基本功能,后来想增加一部分功能自己写,怎么写都报错,希望有高手帮个忙在里面添加一部分程序能实现跳跃和攻击的动画播放~~~跳跃为空格,攻击为鼠标左键~~~~~脚本如下:

private var walkSpeed : float = 1.0;
private var gravity  = 100.0;
private var moveDirection : Vector3 = Vector3.zero;
private var charController : CharacterController;

function Start()
{
charController = GetComponent(CharacterController);
animation.wrapMode = WrapMode.Loop;
}

function Update ()
{
if(charController.isGrounded == true)
{
  if(Input.GetAxis("Vertical") > .1)
  {
   if(Input.GetButton("Run"))
   {
    animation.CrossFade("run");
    walkSpeed = 4;
   }
   else
   {
    animation["walk"].speed = 1;
    animation.CrossFade("walk");
    walkSpeed = 1;
   }
  }
  else if(Input.GetAxis("Vertical") < -.1)
  {
   animation["walk"].speed = -1;
   animation.CrossFade("walk");
   walkSpeed = 1;
  }
  else
  {
   animation.CrossFade("idle");
  }
  
  // Create an animation cycle for when the character is turning on the spot
  if(Input.GetAxis("Horizontal") && !Input.GetAxis("Vertical"))
  {
   animation.CrossFade("walk");
  }
  
  
  transform.eulerAngles.y += Input.GetAxis("Horizontal");
  // Calculate the movement direction (forward motion)
  moveDirection = Vector3(0,0, Input.GetAxis("Vertical"));
  moveDirection = transform.TransformDirection(moveDirection);
   
}

moveDirection.y -= gravity * Time.deltaTime;
charController.Move(moveDirection * (Time.deltaTime * walkSpeed));
}