当前位置: 首页>>代码示例>>C#>>正文


C# CollisionFlags.ToString方法代码示例

本文整理汇总了C#中CollisionFlags.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CollisionFlags.ToString方法的具体用法?C# CollisionFlags.ToString怎么用?C# CollisionFlags.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CollisionFlags的用法示例。


在下文中一共展示了CollisionFlags.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

	public void Update()
	{		
		
		// Get the mouse pressed position in world.
		if ((Input.GetAxis("Fire1")>0 || Input.GetAxis("Fire2")>0) && !isMouseHovering(Input.mousePosition, guiRect, guiRectYFromBottom))
		{
			Ray ray = myCamera.ScreenPointToRay(Input.mousePosition);
			RaycastHit hit;
			if (Physics.Raycast(ray,out hit,rayCastDisntance, layerMask)) 
			{
				currentMoveToPos = hit.point;	
				// Keep target height same as player height for accuracy.
				currentMoveToPos.y = myTransform.position.y;
				//Check if character not already at target position then move
				if(Vector3.Distance(myTransform.position, currentMoveToPos) > distanceError)
				{
					hasTargetPosition = true;
				}				
			}
			buttonDown = true;
		}
		else
		{
			buttonDown = false;
		}
		
		// Make sure the character stays on the ground.
		ApplyGravity ();	
		// Keep target height same as player height for accuracy.
		currentMoveToPos.y = myTransform.position.y;
		
		// Was a successful move enabled.
		if(hasTargetPosition)
		{
	
			// Look at target.
			myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(currentMoveToPos - myTransform.position), rotationSpeed * Time.deltaTime);		
			// Move to target location.
			collisionFlags = controller.Move((myTransform.forward * moveSpeed * Time.deltaTime)+( new Vector3 (0, verticalSpeed, 0)));
			if(animator != null)
			{
				animator.SetBool("run", true);
			}
			// Check if side was hit and stop character.
			if(collisionFlags.ToString().Equals("5"))
			{
				hasTargetPosition = false;
				// Set character to previous position so animation of running/walking happens next.
				collisionFlags = controller.Move((myTransform.forward * -1 * moveSpeed * Time.deltaTime)+( new Vector3 (0, verticalSpeed, 0)));
				if(animator != null)
				{
					animator.SetBool("run", false);
				}
			}
			// Calculate distance to target location and stop if in range.
			if(Vector3.Distance(myTransform.position, currentMoveToPos) <= distanceError && !buttonDown)
			{				
				hasTargetPosition = false;				
				if(animator != null)
				{
					animator.SetBool("run", false);
				}
			}
		}	
		else if(verticalSpeed != 0.0f)
		{
			controller.Move(new Vector3 (0, verticalSpeed, 0));
		}
		
	}
开发者ID:Gapti,项目名称:Starboard_INT,代码行数:70,代码来源:ARPGPlayerMove.cs


注:本文中的CollisionFlags.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。