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


C# CollisionFlags类代码示例

本文整理汇总了C#中CollisionFlags的典型用法代码示例。如果您正苦于以下问题:C# CollisionFlags类的具体用法?C# CollisionFlags怎么用?C# CollisionFlags使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: FixedUpdate

        private void FixedUpdate()
        {
            float speed;
            GetInput(out speed);
            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x;

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;
            Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                               m_CharacterController.height/2f);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            m_MoveDir.x = desiredMove.x*speed;
            m_MoveDir.z = desiredMove.z*speed;

            if (m_CharacterController.isGrounded)
            {
                m_MoveDir.y = -m_StickToGroundForce;
            }
            else
            {
                m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
            }
            m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime);

            ProgressStepCycle(speed);
            UpdateCameraPosition(speed);
        }
开发者ID:kamcneal,项目名称:Conflict-Resolution-CSCI-401,代码行数:29,代码来源:FirstPersonController.cs

示例2: FixedUpdate

    private void FixedUpdate()
    {
        //LookRotation(transform, m_Camera.transform);

            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = transform.forward * m_Input.z + transform.right * m_Input.x + transform.up * m_Input.y;

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;
            Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                               m_CharacterController.height / 2f);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            m_MoveDir.x = desiredMove.x * Math.Abs(translationSpeeds[0]);
            m_MoveDir.z = desiredMove.z * Math.Abs(translationSpeeds[2]);
            m_MoveDir.y = desiredMove.y * Math.Abs(translationSpeeds[1]);
            //desiredMove.x = desiredMove.x * Math.Abs(translationSpeeds[0]);
            //desiredMove.z = desiredMove.z * Math.Abs(translationSpeeds[2]);
            //desiredMove.y = desiredMove.y * Math.Abs(translationSpeeds[1]);

            m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime);

            Vector3 velocity = new Vector3(translationSpeeds[0], translationSpeeds[1], translationSpeeds[2]);
            float speed = velocity.magnitude;
            ProgressStepCycle(speed);
            handleSounds();
    }
开发者ID:Nihav-Jain,项目名称:Space-Between,代码行数:27,代码来源:CustomCharacterController.cs

示例3: FixedUpdate

    void FixedUpdate()
    {
        if(Input.GetAxis("Vertical") < -0.5f && _controller.isGrounded)
        {
            _moveDirection.x = 0;
        }
        else
        {
            _moveDirection.x = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
            _moveDirection.x = Mathf.Clamp(_moveDirection.x, -maxMoveSpeed, maxMoveSpeed);
        }
        _moveDirection.y = Mathf.Max(-Mathf.Abs(maxFallSpeed), _moveDirection.y);
        _cf = _controller.Move(_moveDirection);

        if(!_controller.isGrounded)
        {
            _moveDirection.y -= gravity * Time.deltaTime;
        }
        else
        {
            if(_cf == CollisionFlags.CollidedBelow)
            {
                _moveDirection.y = -0.1f;
                _canDoubleJump = true;
            }
        }
        if(_cf == CollisionFlags.CollidedAbove)
        {
            //audioEffects.PlayCollideSound();
            _moveDirection.y = -0.1f;
        }
    }
开发者ID:kaluluosi,项目名称:quad,代码行数:32,代码来源:CharacterMovement.cs

示例4: GetMove

    void GetMove()
    {
        float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
        float vertical = CrossPlatformInputManager.GetAxis("Vertical");

        float speed = Input.GetKey(runKey) ? speed_run : speed_walk;

        Vector3 desiredDir = (transform.forward*vertical + transform.right*horizontal)
            * Time.deltaTime * speed;

        // apply gtavity
        desiredDir += Physics.gravity * Time.deltaTime;

        m_CollisionFlags = cc.Move(desiredDir);
    }
开发者ID:HaikunHuang,项目名称:TutorialForTaikeQ,代码行数:15,代码来源:CharacterMotor.cs

示例5: Update

    // Update is called once per frame
    void Update()
    {
        //		if (Mathf.Abs (Input.GetAxis ("Horizontal")) > 0) {
        //			_myTransform.Rotate(0, Input.GetAxis("Horizontal") * Time.deltaTime * rotationSpeed, 0);
        //		}

        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Return))
        {
        //	DamageArea.SetActive (false);
            AttackArea.SetActive (true);
        }

        else
        {
        AttackArea.GetComponent<Attack>().ResetSize();
        //			DamageArea.SetActive (true);
           }

        if (_controller.isGrounded) {

            _moveDirection = new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical"));
            _moveDirection = _myTransform.TransformDirection(_moveDirection).normalized;
            _moveDirection *= moveSpeed;

            if(Input.GetKeyDown(KeyCode.Space)){
                _moveDirection.y += jumpHeight;
            }
        }

        else {
            _moveDirection = new Vector3(Input.GetAxis("Horizontal"), _moveDirection.y, Input.GetAxis("Vertical"));
            _moveDirection = transform.TransformDirection(_moveDirection);
            _moveDirection.x *= moveSpeed;
            _moveDirection.z *= moveSpeed;

            if ((_collisionFlags & CollisionFlags.CollidedBelow) == 0){

            }
        }
        _moveDirection.y -= gravity * Time.deltaTime;
        _collisionFlags = _controller.Move(_moveDirection * Time.deltaTime);
    }
开发者ID:BrianPickens,项目名称:BriJames,代码行数:43,代码来源:MoveSide.cs

示例6: FixedUpdate

    private void FixedUpdate()
    {
        float speed;
        GetInput(out speed);

        if (m_MovementDirectionNode == null)
        {
            m_MovementDirectionNode = GameObject.Find(MovementDirectionNodeName);
            return;
        }

        Vector3 movementForward = m_MovementDirectionNode.transform.forward;
        Vector3 movementRight = m_MovementDirectionNode.transform.right;

        // No fly for the moment
        movementForward.y = 0.0f;
        movementForward.Normalize();
        movementRight.y = 0.0f;
        movementRight.Normalize();

        Vector3 desiredMove;
        if (Straffe)
        {
            desiredMove = movementForward * m_Input.y + movementRight * m_Input.x;
        }
        else
        {
            desiredMove = movementForward * m_Input.y;
            this.transform.RotateAround(m_Head.transform.position, Vector3.up, m_Input.x * RotationSpeed * Time.fixedDeltaTime);
        }

        m_Movement.x = desiredMove.x * speed;
        m_Movement.z = desiredMove.z * speed;

        if (!m_CharacterController.isGrounded)
        {
            m_Movement += Physics.gravity * GravityMultiplier * Time.fixedDeltaTime;
        }

        m_CollisionFlags = m_CharacterController.Move(m_Movement * Time.fixedDeltaTime);
    }
开发者ID:ReMinoer,项目名称:SolarVR,代码行数:41,代码来源:VRNavigationController.cs

示例7: update

    void update()
    {
        Vector3 moveVec = Vector3.zero;

        if(moveLeft.IsActive)
        {
            moveVec.x -= Movespeed;
        }
        if(moveRight.IsActive)
        {
            moveVec.x += Movespeed;
        }
        controller.Move(moveVec * Time.deltaTime);
        //if(Jump.IsActive)
        //{
            //moveVec.y -= Gravity;
        //}
        prevFlags = controller.Move(moveVec * Time.deltaTime);

        //if(HideFlags.Has<CollisionFlags>(CollidedSides))
        //{
            //Debug.Log("I HIT SOMETHING..ON THE SIDE");
        //}
    }
开发者ID:johncanace,项目名称:move,代码行数:24,代码来源:PlatformController.cs

示例8: Move

    void Move(float vertical, float horizontal)
    {
        // 카메라의 위치
        Transform camTransform = Camera.main.transform;

        // 캐릭터의 앞 방향
        Vector3 forward = camTransform.TransformDirection(Vector3.forward);
        forward = forward.normalized;
        // 캐릭터의 우측 방향
        Vector3 right = new Vector3(forward.z, 0f, -forward.x);

        // 이동 방향 벡터
        Vector3 targetVector = vertical * forward + horizontal * right;
        targetVector = targetVector.normalized;

        // 이동 방향 계산
        moveDirection = Vector3.RotateTowards(moveDirection, targetVector, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 500f);
        moveDirection = moveDirection.normalized;

        // 이동 양 계산
        Vector3 grav = new Vector3(0f, verticalSpeed, 0f);
        Vector3 movementAmount = (moveDirection * moveSpeed * Time.deltaTime) + grav;

        // 캐릭터를 이동시킨다. 캐릭터가 다른 오브젝트와 마지막으로 충돌된 부분이 어딘지 알 수 있다.
        // 캐릭터가 공중에 있는지 땅에 있는지 알 수 있다
        collisionflags = characterController.Move(movementAmount);
    }
开发者ID:ohs108,项目名称:unity_lecture,代码行数:27,代码来源:SamuraiControl.cs

示例9: Update

    	void Update() 
    	{
    		if (!IsControllable)
    		{
    			return;
    		}
    		
    		if (IsMoving)
    		{
    			Vector3 movement = (moveVector + Vector3.down * gravity) * Time.deltaTime;
    			collisionFlags = characterController.Move(movement);

    			if (trans.forward != moveVector.normalized)
    			{
    				if (LerpRotation)
    				{
    					Vector3 direction = Vector3.Lerp(trans.forward, moveVector, Time.deltaTime * angularSpeed);
    					trans.localRotation = Quaternion.LookRotation(direction);
    				}
    				else
    				{
    					trans.localRotation = Quaternion.LookRotation(moveVector);
    				}
    			}
    		}
    	}
开发者ID:sigmadruid,项目名称:NewMaze,代码行数:26,代码来源:MoveScript.cs

示例10: fixUpdate

        public void fixUpdate()
        {
            float speed;
            GetInput(out speed);
            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = playerObject.transform.forward * input.y + playerObject.transform.right * input.x;

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;
            Physics.SphereCast(playerObject.transform.position, characterController.radius, Vector3.down, out hitInfo,
                               characterController.height / 2f);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            moveDir.x = desiredMove.x * speed;
            moveDir.z = desiredMove.z * speed;

            if (characterController.isGrounded) {
                moveDir.y = -m_StickToGroundForce;
            } else {
                moveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime;
            }

            if (isJumping)
                moveDir.y = playerJumpSpeed;

            collisionFlags = characterController.Move(moveDir * Time.fixedDeltaTime);

            UpdateCameraPosition(speed);
        }
开发者ID:Baensi,项目名称:Assets,代码行数:29,代码来源:UnderwaterMovements.cs

示例11: FixedUpdate

	void FixedUpdate ()
	{
		moveDirection = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
		moveDirection = transform.TransformDirection (moveDirection);
		moveDirection *= speed;

		flags = controller.Move (moveDirection * Time.deltaTime);
	}
开发者ID:markdion,项目名称:Unity-Projects,代码行数:8,代码来源:FPSFlyerMouse.cs

示例12: Move

 private void Move()
 {
     movement =  moveDirection * moveSpeed + new Vector3(0, verticalSpeed, 0);
     movement *= Time.deltaTime;
     collisionFlags = controller.Move(movement);
     Vector3 newDir = Vector3.RotateTowards( transform.forward, moveDirection, Time.deltaTime * rotationSpeed, 0.0f );
     transform.rotation = Quaternion.LookRotation(newDir);
 }
开发者ID:CamdenSegal,项目名称:Old-Tjikko,代码行数:8,代码来源:BeastMovement.cs

示例13: Update

    // Update is called once per frame
    void Update()
    {
        ApplyGravity ();

        v = Input.GetAxisRaw("Vertical");
        h = Input.GetAxisRaw("Horizontal");

        moveDirection = new Vector3(h, verticalSpeed , v).normalized;
        movement = moveDirection * moveSpeed * Time.deltaTime;

        controller.Move(movement);
        collisionFlags = controller.Move(movement);
    }
开发者ID:CamdenSegal,项目名称:Old-Tjikko,代码行数:14,代码来源:Movement.cs

示例14: Update

    // Update is called once per frame
    void Update()
    {
        if(! frozen){
            // make sure the crab stays on the right zposition
            transform.position = new Vector3 (transform.position.x, transform.position.y, zPosition);

            // move the crab
            collisionFlags = controller.Move(velocity * Time.deltaTime);
            if(IsGrounded()){
                setYSpeed(-.05f); // need a very small y velocity to keep the crab grounded every frame
            }

            else{ // accelerate downward
                setYSpeed(getYSpeed() - gravityAcceleration * Time.deltaTime);
            }
        }
    }
开发者ID:TheFatCat,项目名称:Castaway,代码行数:18,代码来源:EnemyController.cs

示例15: Update

    void Update()
    {
        // Apply gravity
        ApplyGravity();

        // Calculate combined motion
        Vector3 movement = (horizontalDirection*horizontalSpeed) + new Vector3(0,verticalSpeed,0) + arialVelocity;
        movement *= Time.deltaTime;

        // Move the controller
        collisionFlags = characterController.Move(movement);

        // While on the ground...
        if (IsGrounded())
        {
            arialVelocity = Vector3.zero;
        }
    }
开发者ID:Clement-E-Todd,项目名称:TeaBot,代码行数:18,代码来源:TBCharacter.cs


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