This commit is contained in:
2021-08-15 12:14:03 +02:00
parent 3ef5d4829f
commit 0bc2441586
331 changed files with 62649 additions and 6610 deletions

View File

@@ -6,8 +6,6 @@ public class Chytac : MonoBehaviour
{
// Start is called before the first frame update
public Rigidbody hrac;
public Vector3 rozdiel;
public Pohybovac mover;
@@ -17,12 +15,19 @@ public class Chytac : MonoBehaviour
bool caught = false;
// Update is called once per frame
Rigidbody hrac;
void start(){
hrac = gameObject.GetComponent<Rigidbody>();
}
void Update()
{
if(Input.GetButtonDown("Fire1")){
//rozdiel = hrac.position -
RaycastHit[] hits = Physics.RaycastAll(transform.position, new Vector3(mover.xrot, 0f, mover.zrot));
float mindist = 15f;
caught = false;
RaycastHit[] hits = Physics.RaycastAll(transform.position, new Vector3(mover.xrot, 0f, mover.zrot), 100);
float mindist = 30f;
foreach (RaycastHit hit in hits){
if (hit.collider.gameObject.name != "Bean"){
@@ -35,15 +40,20 @@ public class Chytac : MonoBehaviour
else{
chytene = hit.collider.gameObject.transform.root.gameObject;
}
rozdiel = hrac.position - chytene.GetComponent<Rigidbody>().position;
caught = true;
if (chytene.TryGetComponent<Rigidbody>(out Rigidbody rbx)){
Debug.Log(hrac.position);
Debug.Log(rbx.position);
Debug.Log("Chytene");
rozdiel = hrac.position - rbx.position;
caught = true;
}
}
}
}
}
if (Input.GetButton("Fire1")){
if(caught){
chytene.GetComponent<Rigidbody>().position = new Vector3(hrac.position.x + rozdiel.x, hrac.position.y + 4, hrac.position.z + rozdiel.z);
chytene.GetComponent<Rigidbody>().position = new Vector3(hrac.position.x + rozdiel.x, hrac.position.y + 4f, hrac.position.z + rozdiel.z);
}
}
}