Показать сообщение отдельно
Старый 05.08.2012, 13:27   #565
cahekp
Разработчик
 
Аватар для cahekp
 
Регистрация: 14.12.2008
Адрес: Томск
Сообщений: 530
Написано 270 полезных сообщений
(для 883 пользователей)
Ответ: Вопросы от новичка

Physics.CapsuleCast
using UnityEngine;
using System.Collections;

public class 
example : MonoBehaviour {
    
void Update() {
        
RaycastHit hit;
        
CharacterController charContr = GetComponent<CharacterController>();
        
Vector3 p1 = transform.position + charContr.center + Vector3.up * -charContr.height * 0.5F;
        
Vector3 p2 = p1 + Vector3.up * charContr.height;
        if (
Physics.CapsuleCast(p1, p2, charContr.radius, transform.forward, out hit, 10))
            
distanceToObstacle = hit.distance;
        
    }
} 
__________________
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
Hurrit (05.08.2012)