Если что-то непонятно и не так, задавайте вопросы.
1) Настройка Rigidbody для стрелы;
2) Код для того чтобы стрела застрягала в мишени (Кому нада пишите)
2.1) Очки в зависемости от попадания в мишень (Кому нада пишите, выводит в консоли но можна сделать в GUI);
3) Сила натягивании тетивы;
Синтаксис:
Используется javascript
/*//////////////////////////////////////////*/
/*/////////////////Sector13////////////////*/
/*/////////////////////////////////////////*/
var projectile : Rigidbody;
var speed = 20;
var Timer : float = 0.0;
var TimerFire : float = 0.0;
function OnGUI () {
windowRect = GUI.Window (0, Rect (20, 20, 200, 50), DoMyWindow, "Сила натягивания: " + Timer);
}
function DoMyWindow (windowID : int) {
GUI.HorizontalSlider (Rect (10, 25, 180, 45), Timer, 0.0, 3);
}
function Update()
{
if( Input.GetButton("Fire1"))
{
Timer += Time.deltaTime;
if (Timer >=3)
{
Timer = 3;
}
}
if( Input.GetButtonUp("Fire1"))
{
TimerFire += (Timer*1.5) * speed;
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, TimerFire ) );
Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
Timer = 0.0;
TimerFire = 0.0;
}
}
/*/////////////////Sector13////////////////*/
/*/////////////////////////////////////////*/
var projectile : Rigidbody;
var speed = 20;
var Timer : float = 0.0;
var TimerFire : float = 0.0;
function OnGUI () {
windowRect = GUI.Window (0, Rect (20, 20, 200, 50), DoMyWindow, "Сила натягивания: " + Timer);
}
function DoMyWindow (windowID : int) {
GUI.HorizontalSlider (Rect (10, 25, 180, 45), Timer, 0.0, 3);
}
function Update()
{
if( Input.GetButton("Fire1"))
{
Timer += Time.deltaTime;
if (Timer >=3)
{
Timer = 3;
}
}
if( Input.GetButtonUp("Fire1"))
{
TimerFire += (Timer*1.5) * speed;
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, TimerFire ) );
Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider );
Timer = 0.0;
TimerFire = 0.0;
}
}