Advertisement
codisinmyvines

unityainur

Dec 1st, 2021
1,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 KB | None | 0 0
  1. //сам интерфейс
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. interface IInteractable
  7. {
  8.     void Interact();
  9. }
  10. //куб
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using UnityEngine;
  14.  
  15. public class CubeInteract : MonoBehaviour, IInteractable
  16. {
  17.     private float movementSpeed = 5f;
  18.     public void Interact()
  19.     {
  20.         float horizontalInput = Input.GetAxis("Horizontal");
  21.         float verticalInput = Input.GetAxis("Vertical");
  22.  
  23.         transform.position = transform.position + new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
  24.         Debug.Log(transform.position);
  25.     }
  26.     void Update()
  27.     {
  28.         Interact();
  29.     }
  30. }
  31. //сфера
  32. using System.Collections;
  33. using System.Collections.Generic;
  34. using UnityEngine;
  35.  
  36. public class SphereInteract : MonoBehaviour, IInteractable
  37. {
  38.     private float movementSpeed = 5f;
  39.     //private Vector3 changeScale;
  40.     public void Interact()
  41.     {
  42.         float horizontalInput = Input.GetAxis("Horizontal");
  43.         float verticalInput = Input.GetAxis("Vertical");
  44.         //transform.position = transform.position + new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
  45.         //transform.Rotate(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
  46.         transform.localScale += new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
  47.     }
  48.  
  49.     // Start is called before the first frame update
  50.     void Start()
  51.     {
  52.        // changeScale = new Vector3(0, 0, 0);
  53.     }
  54.  
  55.     // Update is called once per frame
  56.     void Update()
  57.     {
  58.         Interact();
  59.     }
  60. }
  61. //цилиндр
  62. using System.Collections;
  63. using System.Collections.Generic;
  64. using UnityEngine;
  65.  
  66. public class CylinderInteract : MonoBehaviour, IInteractable
  67. {
  68.     private float movementSpeed = 40f;
  69.     public void Interact()
  70.     {
  71.         float horizontalInput = Input.GetAxis("Horizontal");
  72.         float verticalInput = Input.GetAxis("Vertical");
  73.         transform.Rotate(-verticalInput * movementSpeed * Time.deltaTime, 0, -horizontalInput * movementSpeed * Time.deltaTime);
  74.     }
  75.     void Update()
  76.     {
  77.         Interact();
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement