Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //сам интерфейс
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- interface IInteractable
- {
- void Interact();
- }
- //куб
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CubeInteract : MonoBehaviour, IInteractable
- {
- private float movementSpeed = 5f;
- public void Interact()
- {
- float horizontalInput = Input.GetAxis("Horizontal");
- float verticalInput = Input.GetAxis("Vertical");
- transform.position = transform.position + new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
- Debug.Log(transform.position);
- }
- void Update()
- {
- Interact();
- }
- }
- //сфера
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SphereInteract : MonoBehaviour, IInteractable
- {
- private float movementSpeed = 5f;
- //private Vector3 changeScale;
- public void Interact()
- {
- float horizontalInput = Input.GetAxis("Horizontal");
- float verticalInput = Input.GetAxis("Vertical");
- //transform.position = transform.position + new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
- //transform.Rotate(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
- transform.localScale += new Vector3(horizontalInput * movementSpeed * Time.deltaTime, verticalInput * movementSpeed * Time.deltaTime, 0);
- }
- // Start is called before the first frame update
- void Start()
- {
- // changeScale = new Vector3(0, 0, 0);
- }
- // Update is called once per frame
- void Update()
- {
- Interact();
- }
- }
- //цилиндр
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CylinderInteract : MonoBehaviour, IInteractable
- {
- private float movementSpeed = 40f;
- public void Interact()
- {
- float horizontalInput = Input.GetAxis("Horizontal");
- float verticalInput = Input.GetAxis("Vertical");
- transform.Rotate(-verticalInput * movementSpeed * Time.deltaTime, 0, -horizontalInput * movementSpeed * Time.deltaTime);
- }
- void Update()
- {
- Interact();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement