nevem
This commit is contained in:
@@ -16,17 +16,14 @@ public class Chytac : MonoBehaviour
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
Rigidbody hrac;
|
||||
|
||||
void start(){
|
||||
hrac = gameObject.GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Debug.DrawRay(transform.position, new Vector3(-mover.zrot, 10f, mover.xrot), Color.blue, 0);
|
||||
Debug.Log(new Vector3(-mover.zrot, 10f, mover.xrot));
|
||||
if(Input.GetButtonDown("Fire1")){
|
||||
caught = false;
|
||||
RaycastHit[] hits = Physics.RaycastAll(transform.position, new Vector3(mover.xrot, 0f, mover.zrot), 100);
|
||||
RaycastHit[] hits = Physics.RaycastAll(transform.position, new Vector3(-mover.zrot, 0f, mover.xrot), 100);
|
||||
float mindist = 30f;
|
||||
|
||||
foreach (RaycastHit hit in hits){
|
||||
@@ -41,10 +38,10 @@ public class Chytac : MonoBehaviour
|
||||
chytene = hit.collider.gameObject.transform.root.gameObject;
|
||||
}
|
||||
if (chytene.TryGetComponent<Rigidbody>(out Rigidbody rbx)){
|
||||
Debug.Log(hrac.position);
|
||||
Debug.Log(transform.position);
|
||||
Debug.Log(rbx.position);
|
||||
Debug.Log("Chytene");
|
||||
rozdiel = hrac.position - rbx.position;
|
||||
rozdiel = transform.position - rbx.position;
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +50,7 @@ public class Chytac : MonoBehaviour
|
||||
}
|
||||
if (Input.GetButton("Fire1")){
|
||||
if(caught){
|
||||
chytene.GetComponent<Rigidbody>().position = new Vector3(hrac.position.x + rozdiel.x, hrac.position.y + 4f, hrac.position.z + rozdiel.z);
|
||||
chytene.GetComponent<Rigidbody>().position = new Vector3(transform.position.x + rozdiel.x, transform.position.y + 4f, transform.position.z + rozdiel.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,8 +10,8 @@ public class Pohybovac : MonoBehaviour
|
||||
public float look_speed = 50f;
|
||||
|
||||
public float walk_speed = 100f;
|
||||
public float xrot = 0f;
|
||||
public float zrot = 0f;
|
||||
public float xrot = 0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -21,14 +21,14 @@ public class Pohybovac : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
xrot += Input.GetAxisRaw("Mouse Y") * Time.deltaTime * look_speed;
|
||||
xrot = Mathf.Clamp(xrot, -10f, 10f);
|
||||
kamera.localRotation = Quaternion.AngleAxis(xrot, new Vector3(-1f, 0f, 0f));
|
||||
zrot += Input.GetAxisRaw("Mouse X") * Time.deltaTime * look_speed;
|
||||
if (zrot >= 180 || zrot <= -180){
|
||||
zrot = 0;
|
||||
zrot += Input.GetAxisRaw("Mouse Y") * Time.deltaTime * look_speed;
|
||||
zrot = Mathf.Clamp(zrot, -10f, 10f);
|
||||
kamera.localRotation = Quaternion.AngleAxis(zrot, new Vector3(-1f, 0f, 0f));
|
||||
xrot += Input.GetAxisRaw("Mouse X") * Time.deltaTime * look_speed;
|
||||
if (xrot >= 180 || xrot <= -180){
|
||||
xrot = 0;
|
||||
}
|
||||
rb.rotation = Quaternion.AngleAxis(zrot, new Vector3(0f, 1f, 0f));
|
||||
rb.rotation = Quaternion.AngleAxis(xrot, new Vector3(0f, 1f, 0f));
|
||||
|
||||
float xmove = Input.GetAxisRaw("Horizontal") * Time.deltaTime * walk_speed * 5000f;
|
||||
float zmove = Input.GetAxisRaw("Vertical") * Time.deltaTime * walk_speed * 10000f;
|
||||
|
Reference in New Issue
Block a user