Вторник, 19 Марта 2024, 12:59

Приветствую Вас Гость

[ Новые сообщения · Игроделы · Правила · Поиск ]
  • Страница 1 из 16
  • 1
  • 2
  • 3
  • 15
  • 16
  • »
Форум игроделов » Записи участника » iNikit [307]
Результаты поиска
iNikitДата: Суббота, 01 Декабря 2012, 18:06 | Сообщение # 1 | Тема: Как сделали Bad Piggies на Unity3D ?
участник
Сейчас нет на сайте
2D Toolkit, не?


Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 25 Ноября 2012, 19:55 | Сообщение # 2 | Тема: Вопрос-[ответ] по Unity
участник
Сейчас нет на сайте
Есть ли у кого-нибудь FirstPersonControl.js на C#? (Из стандартного пакета "Standart Assets (mobile)")

UPD: Okay. Переписал на C# (через конвертер и мою клавиатуру):
Code

using UnityEngine;
using System.Collections;

[RequireComponent (typeof(CharacterController))]
public class FirstPersonControl : MonoBehaviour
{
//////////////////////////////////////////////////////////////
// FirstPersonControl.cs
//
// FirstPersonControl creates a control scheme where the camera   
// location and controls directly map to being in the first person.
// The left pad is used to move the character, and the
// right pad is used to rotate the character. A quick double-tap
// on the right joystick will make the character jump.
//
// If no right pad is assigned, then tilt is used for rotation
// you double tap the left pad to jump
//
// C# version by iNikit
// http://vk.com/iNikit
//////////////////////////////////////////////////////////////

   // This script must be attached to a GameObject that has a CharacterController
   public MPJoystick moveTouchPad;
   public MPJoystick rotateTouchPad;      // If unassigned, tilt is used

   public Transform cameraPivot;      // The transform used for camera rotation

   public float forwardSpeed = 4;
   public float backwardSpeed = 1;
   public float sidestepSpeed = 1;
   public float jumpSpeed = 8;
   public float inAirMultiplier = 0.25f;     // Limiter for ground speed while jumping
   public Vector2 rotationSpeed = new Vector2 (50, 25);    // Camera rotation speed for each axis
   public float tiltPositiveYAxis = 0.6f;
   public float tiltNegativeYAxis = 0.4f;
   public float tiltXAxisMinimum = 0.1f;
   private Transform thisTransform;
   private CharacterController character;
   private Vector3 cameraVelocity;
   private Vector3 velocity;      // Used for continuing momentum while in air
   private bool canJump = true;

   void  Start ()
   {
    // Cache component lookup at startup instead of doing this every frame    
    thisTransform = GetComponent< Transform > ();
    character = GetComponent< CharacterController > ();   

    // Move the character to the correct start position in the level, if one exists
    GameObject spawn = GameObject.Find ("PlayerSpawn");
    if (spawn)
     thisTransform.position = spawn.transform.position;
   }

   void  OnEndGame ()
   {
    // Disable joystick when the game ends   
    moveTouchPad.Disable ();
     
    if (rotateTouchPad)
     rotateTouchPad.Disable ();   

    // Don't allow any more control changes when the game ends
    this.enabled = false;
   }

   void  Update ()
   {
    Vector3 movement = thisTransform.TransformDirection (new Vector3 (moveTouchPad.position.x, 0, moveTouchPad.position.y));

    // We only want horizontal movement
    movement.y = 0;
    movement.Normalize ();

    // Apply movement from move joystick
    Vector2 absJoyPos = new Vector2 (Mathf.Abs (moveTouchPad.position.x), Mathf.Abs (moveTouchPad.position.y));   
    if (absJoyPos.y > absJoyPos.x) {
     if (moveTouchPad.position.y > 0)
      movement *= forwardSpeed * absJoyPos.y;
     else
      movement *= backwardSpeed * absJoyPos.y;
    } else
     movement *= sidestepSpeed * absJoyPos.x;    
     
    // Check for jump
    if (character.isGrounded) {    
     bool jump = false;
     MPJoystick touchPad;
     if (rotateTouchPad)
      touchPad = rotateTouchPad;
     else
      touchPad = moveTouchPad;
     
     if (!touchPad.IsFingerDown ())
      canJump = true;
      
     if (canJump && touchPad.tapCount >= 2) {
      jump = true;
      canJump = false;
     }   
      
     if (jump) {
      // Apply the current movement to launch velocity    
      velocity = character.velocity;
      velocity.y = jumpSpeed;   
     }
    } else {     
     // Apply gravity to our velocity to diminish it over time
     velocity.y += Physics.gravity.y * Time.deltaTime;
        
     // Adjust additional movement while in-air
     movement.x *= inAirMultiplier;
     movement.z *= inAirMultiplier;
    }
      
    movement += velocity;   
    movement += Physics.gravity;
    movement *= Time.deltaTime;
     
    // Actually move the character   
    character.Move (movement);
     
    if (character.isGrounded)
    // Remove any persistent velocity after landing   
     velocity = Vector3.zero;
     
    // Apply rotation from rotation joystick
    if (character.isGrounded) {
     Vector2 camRotation = Vector2.zero;
      
     if (rotateTouchPad)
      camRotation = rotateTouchPad.position;
     else {
      // Use tilt instead
//   print( iPhoneInput.acceleration );
      Vector3 acceleration = Input.acceleration;
      float absTiltX = Mathf.Abs (acceleration.x);
      if (acceleration.z < 0 && acceleration.x < 0) {
       if (absTiltX >= tiltPositiveYAxis)
        camRotation.y = (absTiltX - tiltPositiveYAxis) / (1 - tiltPositiveYAxis);
       else if (absTiltX <= tiltNegativeYAxis)
        camRotation.y = -(tiltNegativeYAxis - absTiltX) / tiltNegativeYAxis;
      }
       
      if (Mathf.Abs (acceleration.y) >= tiltXAxisMinimum)
       camRotation.x = -(acceleration.y - tiltXAxisMinimum) / (1 - tiltXAxisMinimum);
     }
      
     camRotation.x *= rotationSpeed.x;
     camRotation.y *= rotationSpeed.y;
     camRotation *= Time.deltaTime;
      
     // Rotate the character around world-y using x-axis of joystick
     thisTransform.Rotate (0, camRotation.x, 0, Space.World);
      
     // Rotate only the camera with y-axis input
     cameraPivot.Rotate (-camRotation.y, 0, 0);
    }
   }
}

А вот найденный мною Joystick.js на C#:
Code

using UnityEngine;
     
/**
   * File: MPJoystick.cs
   * Author: Chris Danielson of (monkeyprism.com)
   *
// USED TO BE: Joystick.js taken from Penelope iPhone Tutorial
//
// Joystick creates a movable joystick (via GUITexture) that
// handles touch input, taps, and phases. Dead zones can control
// where the joystick input gets picked up and can be normalized.
//
// Optionally, you can enable the touchPad property from the editor
// to treat this Joystick as a TouchPad. A TouchPad allows the finger
// to touch down at any point and it tracks the movement relatively
// without moving the graphic
*/
     
[RequireComponent(typeof(GUITexture))]
public class MPJoystick : MonoBehaviour
{
   class Boundary {
    public Vector2 min = Vector2.zero;
    public Vector2 max = Vector2.zero;
   }
     
   private static MPJoystick[] joysticks;     // A static collection of all joysticks
   private static bool enumeratedJoysticks = false;
   private static float tapTimeDelta = 0.3f;    // Time allowed between taps
     
   public bool touchPad;
   public Vector2 position = Vector2.zero;
   public Rect touchZone;
   public Vector2 deadZone = Vector2.zero;      // Control when position is output
   public bool normalize = false;        // Normalize output after the dead-zone?
   public int tapCount;
     
   private int lastFingerId = -1;        // Finger last used for this joystick
   private float tapTimeWindow;       // How much time there is left for a tap to occur
   private Vector2 fingerDownPos;
   //private float fingerDownTime;
   //private float firstDeltaTime = 0.5f;
     
   private GUITexture gui;
   private Rect defaultRect;        // Default position / extents of the joystick graphic
   private Boundary guiBoundary = new Boundary();   // Boundary for joystick graphic
   private Vector2 guiTouchOffset;      // Offset to apply to touch input
   private Vector2 guiCenter;       // Center of joystick
     
   void Start() {
    gui = (GUITexture)GetComponent(typeof(GUITexture));
     
    defaultRect = gui.pixelInset;
    defaultRect.x += transform.position.x * Screen.width;// + gui.pixelInset.x; // -  Screen.width * 0.5;
    defaultRect.y += transform.position.y * Screen.height;// - Screen.height * 0.5;
     
    transform.position = Vector3.zero;
     
    if (touchPad) {
     // If a texture has been assigned, then use the rect ferom the gui as our touchZone
     if ( gui.texture )
      touchZone = defaultRect;
    } else {
     guiTouchOffset.x = defaultRect.width * 0.5f;
     guiTouchOffset.y = defaultRect.height * 0.5f;
     
     // Cache the center of the GUI, since it doesn't change
     guiCenter.x = defaultRect.x + guiTouchOffset.x;
     guiCenter.y = defaultRect.y + guiTouchOffset.y;
     
     // Let's build the GUI boundary, so we can clamp joystick movement
     guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
     guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
     guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
     guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
    }
   }
     
   public Vector2 getGUICenter() {
    return guiCenter;
   }
     
   public void Disable() {
    gameObject.active = false;
    //enumeratedJoysticks = false;
   }
     
   private void ResetJoystick() {
    gui.pixelInset = defaultRect;
    lastFingerId = -1;
    position = Vector2.zero;
    fingerDownPos = Vector2.zero;
   }
     
   public bool IsFingerDown() {
    return (lastFingerId != -1);
   }
     
   public void LatchedFinger(int fingerId) {
    // If another joystick has latched this finger, then we must release it
    if ( lastFingerId == fingerId )
     ResetJoystick();
   }
     
   void Update() {
    if (!enumeratedJoysticks) {
     // Collect all joysticks in the game, so we can relay finger latching messages
     joysticks = (MPJoystick[])FindObjectsOfType(typeof(MPJoystick));
     enumeratedJoysticks = true;
    }
     
    int count = Input.touchCount;
     
    if ( tapTimeWindow > 0 )
     tapTimeWindow -= Time.deltaTime;
    else
     tapCount = 0;
     
    if ( count == 0 )
     ResetJoystick();
    else
    {
     for(int i = 0; i < count; i++) {
      Touch touch = Input.GetTouch(i);
      Vector2 guiTouchPos = touch.position - guiTouchOffset;
     
      bool shouldLatchFinger = false;
      if (touchPad) {
       if (touchZone.Contains(touch.position))
        shouldLatchFinger = true;
      }
      else if (gui.HitTest(touch.position)) {
       shouldLatchFinger = true;
      }
     
      // Latch the finger if this is a new touch
      if (shouldLatchFinger && (lastFingerId == -1 || lastFingerId != touch.fingerId )) {
     
       if (touchPad) {
        //gui.color.a = 0.15;
        lastFingerId = touch.fingerId;
        //fingerDownPos = touch.position;
        //fingerDownTime = Time.time;
       }
     
       lastFingerId = touch.fingerId;
     
       // Accumulate taps if it is within the time window
       if ( tapTimeWindow > 0 )
        tapCount++;
       else {
        tapCount = 1;
        tapTimeWindow = tapTimeDelta;
       }
     
       // Tell other joysticks we've latched this finger
       //for (  j : Joystick in joysticks )
       foreach (MPJoystick j in joysticks) {
        if (j != this)
         j.LatchedFinger( touch.fingerId );
       }
      }
     
      if ( lastFingerId == touch.fingerId ) {
       // Override the tap count with what the iPhone SDK reports if it is greater
       // This is a workaround, since the iPhone SDK does not currently track taps
       // for multiple touches
       if ( touch.tapCount > tapCount )
        tapCount = touch.tapCount;
     
       if ( touchPad ) {
        // For a touchpad, let's just set the position directly based on distance from initial touchdown
        position.x = Mathf.Clamp( ( touch.position.x - fingerDownPos.x ) / ( touchZone.width / 2 ), -1, 1 );
        position.y = Mathf.Clamp( ( touch.position.y - fingerDownPos.y ) / ( touchZone.height / 2 ), -1, 1 );
       } else {
        // Change the location of the joystick graphic to match where the touch is
        Rect r = gui.pixelInset;
        r.x =  Mathf.Clamp( guiTouchPos.x, guiBoundary.min.x, guiBoundary.max.x );
        r.y =  Mathf.Clamp( guiTouchPos.y, guiBoundary.min.y, guiBoundary.max.y );
        gui.pixelInset = r;
       }
     
       if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
        ResetJoystick();
      }
     }
    }
     
    if (!touchPad) {
     // Get a value between -1 and 1 based on the joystick graphic location
     position.x = ( gui.pixelInset.x + guiTouchOffset.x - guiCenter.x ) / guiTouchOffset.x;
     position.y = ( gui.pixelInset.y + guiTouchOffset.y - guiCenter.y ) / guiTouchOffset.y;
    }
     
    // Adjust for dead zone
    var absoluteX = Mathf.Abs( position.x );
    var absoluteY = Mathf.Abs( position.y );
     
    if (absoluteX < deadZone.x) {
     // Report the joystick as being at the center if it is within the dead zone
     position.x = 0;
    }
    else if (normalize) {
     // Rescale the output after taking the dead zone into account
     position.x = Mathf.Sign( position.x ) * ( absoluteX - deadZone.x ) / ( 1 - deadZone.x );
    }
     
    if (absoluteY < deadZone.y) {
     // Report the joystick as being at the center if it is within the dead zone
     position.y = 0;
    }
    else if (normalize) {
     // Rescale the output after taking the dead zone into account
     position.y = Mathf.Sign( position.y ) * ( absoluteY - deadZone.y ) / ( 1 - deadZone.y );
    }
     
   }
     
}



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Воскресенье, 25 Ноября 2012, 20:47
iNikitДата: Среда, 07 Ноября 2012, 13:38 | Сообщение # 3 | Тема: Пиксельная заливка
участник
Сейчас нет на сайте
andarky, готового конечно не ищет. Всё самому делать надо. wink


Самый лучший юзер GCUP :3
iNikitДата: Вторник, 06 Ноября 2012, 18:56 | Сообщение # 4 | Тема: Помогите перевести JS в C#
участник
Сейчас нет на сайте
Quote (Steep)
Но тот код что я дал это в JS был

Он и в C# работает.
Code

   .-´¯¯¯`-.
,´         `.
|            \
|             \
\           _  \
,\  _    ,´¯,/¯)\
( q \ \,´ ,´ ,´¯)
  `._,)     -´,-´)
    \/         ,´/
     )        / /
    /       ,´-´



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Вторник, 06 Ноября 2012, 18:56
iNikitДата: Воскресенье, 04 Ноября 2012, 14:17 | Сообщение # 5 | Тема: Hand-made участников форума
участник
Сейчас нет на сайте
Всё ровно у меня самый офигенный домик из пластелина biggrin

И пофиг, что ему уже 7 лет biggrin



Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 04 Ноября 2012, 14:13 | Сообщение # 6 | Тема: Господь бог - программист?
участник
Сейчас нет на сайте
Quote (SkyOrvias)
мы ИИ, а Вселенная - Vselennaya OS, планеты - проги, земля - игра, галактики - папки

Я всю жизнь так думал.



Самый лучший юзер GCUP :3
iNikitДата: Четверг, 01 Ноября 2012, 22:50 | Сообщение # 7 | Тема: PHP5
участник
Сейчас нет на сайте
imperator12, эм.
> — больше
< — меньше
Ты перепутал знаки. 10 больше 8, поэтому и выводится Good day. biggrin



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Четверг, 01 Ноября 2012, 22:51
iNikitДата: Четверг, 01 Ноября 2012, 15:17 | Сообщение # 8 | Тема: Конкурс по созданию уроков по движку Unity3D
участник
Сейчас нет на сайте
lapendown, за 5000 рублей с удовольствием выиграю этот конкурс.


Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 28 Октября 2012, 18:00 | Сообщение # 9 | Тема: Помогите придумать домен
участник
Сейчас нет на сайте
фр.шалаш.рф


Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 28 Октября 2012, 17:42 | Сообщение # 10 | Тема: Рифмаплёт
участник
Сейчас нет на сайте
У тебя во рту томат! biggrin
Йод



Самый лучший юзер GCUP :3
iNikitДата: Суббота, 27 Октября 2012, 19:44 | Сообщение # 11 | Тема: Компиляция в андроид
участник
Сейчас нет на сайте
Только управление под тач напиши, оптимизируй модели и скрипты.


Самый лучший юзер GCUP :3
iNikitДата: Среда, 24 Октября 2012, 15:49 | Сообщение # 12 | Тема: Расстановка GUI на камере
участник
Сейчас нет на сайте
Quote (Aleks_Vast)
Тут объект становисят по центру, но проблема: он начинается от середины монитора

Хм... Странно... А Вас, уважаемый, не смущает эта часть строчки?
Quote (Aleks_Vast)
Screen.width / 2 - 50, Screen.height / 2



Самый лучший юзер GCUP :3
iNikitДата: Вторник, 23 Октября 2012, 20:08 | Сообщение # 13 | Тема: UNITY сломался
участник
Сейчас нет на сайте
Quote (andarky)
Очень давно не включала его
и вот решил... НО!

Резко возник вопрос: Ты парень или девушка?
Может быть следовало бы сразу перевести ошибку на русский, понять самому, попытаться решить и если ничего не получится, то создать топик? Это так, на будущее.



Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 21 Октября 2012, 23:15 | Сообщение # 14 | Тема: Свои фото
участник
Сейчас нет на сайте
Quote (BannedInDC)
со своим лицом уж сильно похож на страшную девочку

Действительно так. К этому времени моё лицо сильно изменилось с тех пор, в принципе, как и фигура. Меня очень часто принимают за девочку. Короткая стрижка тоже не помогла. После мне стало абсолютно похер на всё. что говорят окружающие и я стал ходить так, как я хочу.



Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 21 Октября 2012, 22:36 | Сообщение # 15 | Тема: Свои фото
участник
Сейчас нет на сайте
Quote (SkyOrvias)
пашпарт в 8 лет получил?)

Даа, мы в Одессу к родственникам ездили smile
В любом случае, я подстригся. 2 см срезали. biggrin
Quote (Маркер)
А почему ты так была похожа на мальчика до этого?

Знал же, что быдло везде есть. Спасибо, этот сайт прошёл мой тест. biggrin
EchoIT, это всё из-за боязни парикмахерских fear



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Воскресенье, 21 Октября 2012, 22:39
iNikitДата: Воскресенье, 21 Октября 2012, 18:51 | Сообщение # 16 | Тема: Свои фото
участник
Сейчас нет на сайте
7 лет назад:

6 месяцев назад:

А что сейчас... Вам лучше не знать biggrin



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Воскресенье, 21 Октября 2012, 18:51
iNikitДата: Воскресенье, 21 Октября 2012, 17:11 | Сообщение # 17 | Тема: Dungelot
участник
Сейчас нет на сайте
У меня одного не капает на 16 подземелье?


Самый лучший юзер GCUP :3
iNikitДата: Воскресенье, 21 Октября 2012, 12:57 | Сообщение # 18 | Тема: Нужна помощь с сохранением игры!
участник
Сейчас нет на сайте
Quote (Timujin61)
Я знаю, но я учу unity3d всего-лишь месяц и я многого ещё не знаю

Это тебя не оправдывает. Думать нужно всегда.
Вот тебе привет от лиги труда:
Сохранение игровых данных через XML, Простая загрузка через xml



Самый лучший юзер GCUP :3
iNikitДата: Четверг, 18 Октября 2012, 17:53 | Сообщение # 19 | Тема: Испорченный телефон
участник
Сейчас нет на сайте
Покрыл мезинец


Самый лучший юзер GCUP :3
iNikitДата: Четверг, 18 Октября 2012, 15:51 | Сообщение # 20 | Тема: AINavMesh
участник
Сейчас нет на сайте
Quote (FORFUN)
никто ни чем не может помочь.. офигенное сообщество...

Почему тебе кто-то помогать обязан?
Цитата из правил форума:
Quote

Репутация влияет на отношение пользователей к пользователям. Администрация не рекомендует иметь дела с пользователями с отрицательным уровнем репутации. Пользователи с низким или отрицательным уровнем репутации могут быть заблокированы с первого раза и навсегда, т.к. администрация ориентируется и на репутацию как на показатель ценности пользователя.

По тому, что написано в правилах, с тобой лучше не связываться и ты бесценен. Вот почему ни у кого нет желания тебе помогать.
Quote (FORFUN)
idle анимация воспроизводится еще и тогда, когда AI идет обратно, а должна run воспроизводиться, кто может помочь?

Может... Просто следует слова idle и run поменять местами в коде?



Самый лучший юзер GCUP :3


Сообщение отредактировал iNikit - Четверг, 18 Октября 2012, 15:52
Форум игроделов » Записи участника » iNikit [307]
  • Страница 1 из 16
  • 1
  • 2
  • 3
  • 15
  • 16
  • »
Поиск:

Все права сохранены. GcUp.ru © 2008-2024 Рейтинг