Last active
September 12, 2020 12:34
-
-
Save takoyakiroom/7bfe381980227f51f9c1bee93992bb88 to your computer and use it in GitHub Desktop.
BodyCollider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//======= Copyright (c) Valve Corporation, All rights reserved. =============== | |
// | |
// Purpose: Collider dangling from the player's head | |
// | |
//============================================================================= | |
using UnityEngine; | |
using System.Collections; | |
namespace Valve.VR.InteractionSystem | |
{ | |
[RequireComponent( typeof( CapsuleCollider ) )] | |
public class BodyCollider : MonoBehaviour | |
{ | |
public Transform head; | |
void Awake() | |
{ | |
} | |
void FixedUpdate() | |
{ | |
// headの位置に合わせる(高さは重力に任せるので合わせない) | |
Vector3 pos = transform.position; | |
pos.x = head.transform.position.x; | |
pos.z = head.transform.position.z; | |
transform.position = pos; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment