Глупо обращатся за помощью без кода, но это так
У меня есть что то но оно мне не нравится
Синтаксис:
Используется csharp
using System;
using System.Collections;
using System.Linq;
using UnityEngine;
public class Take : MonoBehaviour
{
float distance = 3;
public Transform pos;
private Rigidbody rb;
private Take_Is taked;
private void Start ()
{
rb = GetComponent<Rigidbody>();
taked = GameObject.Find("First Person Controller").GetComponent<Take_Is>();
}
private void OnMouseDown()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, distance) && taked.Take==false)
{
taked.Take = true;
rb.isKinematic = true;
rb.MovePosition(pos.position);
}
}
private void FixedUpdate ()
{
if (rb.isKinematic)
{
transform.position = pos.position;
if (Input.GetKeyDown(KeyCode.Mouse0) && taked.Take==true)
{
taked.Take = false;
rb.isKinematic = false;
rb.AddForce(Camera.main.transform.forward * 500);
}
}
}
}
using System.Collections;
using System.Linq;
using UnityEngine;
public class Take : MonoBehaviour
{
float distance = 3;
public Transform pos;
private Rigidbody rb;
private Take_Is taked;
private void Start ()
{
rb = GetComponent<Rigidbody>();
taked = GameObject.Find("First Person Controller").GetComponent<Take_Is>();
}
private void OnMouseDown()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, distance) && taked.Take==false)
{
taked.Take = true;
rb.isKinematic = true;
rb.MovePosition(pos.position);
}
}
private void FixedUpdate ()
{
if (rb.isKinematic)
{
transform.position = pos.position;
if (Input.GetKeyDown(KeyCode.Mouse0) && taked.Take==true)
{
taked.Take = false;
rb.isKinematic = false;
rb.AddForce(Camera.main.transform.forward * 500);
}
}
}
}
Мне нужно:
1. Возможность переворота объектов на колесико мышки
2. Я не хочу чтобы объект привязывался к позиции Take, Я хочу чтобы он брался с позиции где и лежал (стоял)
3. Чтобы можно было нормально выбросить объект - в моей нароботке пока не отведешь камеру от объекта то не выбросишь его
Я хочу сделать принцип как в играх - My Summer Car, Mon Bazou
Я буду рад если мне помогут