Gameplay improvement
This commit is contained in:
@@ -71,13 +71,13 @@ public class AIController : MonoBehaviour
|
||||
inputs[AiInputs.VERTICAL] = 1;
|
||||
}
|
||||
|
||||
Debug.DrawRay(transform.position, transform.TransformDirection(-Vector3.forward) * 8, Color.magenta, 0, false);
|
||||
|
||||
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(this.angleToDestination * 10) / 10;
|
||||
if (this.distanceToTarget < this.turnRadius)
|
||||
{
|
||||
inputs[AiInputs.HORIZONTAL] = Mathf.Floor(-this.angleToBall * 10) / 10;
|
||||
Debug.DrawRay(transform.position, transform.TransformDirection(-Vector3.forward) * 10, Color.magenta, 0,false);
|
||||
if (Physics.Raycast(transform.position, transform.TransformDirection(-Vector3.forward), 10))
|
||||
if (Physics.Raycast(transform.position, transform.TransformDirection(-Vector3.forward), 8))
|
||||
{
|
||||
inputs[AiInputs.BOOST] = 1;
|
||||
}
|
||||
@@ -85,6 +85,7 @@ public class AIController : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (this.distanceToBall < this.turnRadius)
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
public class ForceZone : MonoBehaviour
|
||||
{
|
||||
public float force = 0;
|
||||
public GameObject player;
|
||||
public GameObject forceOrigin;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -20,7 +20,7 @@ public class ForceZone : MonoBehaviour
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
Vector3 direction = other.transform.position - this.player.transform.position;
|
||||
Vector3 direction = other.transform.position - this.forceOrigin.transform.position;
|
||||
Debug.DrawRay(this.transform.position, direction);
|
||||
|
||||
Rigidbody otherRigidbody = other.transform.GetComponent<Rigidbody>();
|
||||
|
||||
@@ -33,6 +33,7 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@@ -48,11 +49,20 @@ public class PlayerController : MonoBehaviour
|
||||
aiInput = this.aiController.GetInputs();
|
||||
rotationDirection = aiInput[AiInputs.HORIZONTAL];
|
||||
movementDirection = aiInput[AiInputs.VERTICAL];
|
||||
|
||||
}
|
||||
|
||||
if (this.useController) {
|
||||
//Debug.Log(Input.GetAxis("VerticalBack" + this.playerNumber));
|
||||
movementDirection = Input.GetAxis("VerticalBack" + this.playerNumber) > 0 ? -1 : movementDirection;
|
||||
movementDirection = Input.GetAxis("Horizontal" + this.playerNumber) != 0 ? 1 : movementDirection;
|
||||
|
||||
float horizontal = Input.GetAxis("Horizontal3");
|
||||
float vertical = Input.GetAxis("Vertical3");
|
||||
if (movementDirection != 0)
|
||||
{
|
||||
Vector3 direction = new Vector3(horizontal, 0, -vertical).normalized;
|
||||
this.transform.rotation = Quaternion.LookRotation(direction, Vector3.up);
|
||||
}
|
||||
}
|
||||
|
||||
//Links
|
||||
@@ -67,18 +77,19 @@ public class PlayerController : MonoBehaviour
|
||||
transform.Rotate(Vector3.up, -this.rotationSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
Debug.Log(movementDirection);
|
||||
//Forward
|
||||
if (movementDirection > 0)
|
||||
if (movementDirection != 0)
|
||||
{
|
||||
this.rb.drag = this.drag;
|
||||
this.rb.AddRelativeForce(Vector3.forward * this.movementSpeed * Time.deltaTime, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
//Zurück
|
||||
if (movementDirection < 0)
|
||||
{
|
||||
this.rb.AddRelativeForce(Vector3.back * this.movementSpeed / 2 * Time.deltaTime, ForceMode.Impulse);
|
||||
}
|
||||
//if (movementDirection < 0)
|
||||
//{
|
||||
// this.rb.AddRelativeForce(Vector3.back * this.movementSpeed / 2 * Time.deltaTime, ForceMode.Impulse);
|
||||
//}
|
||||
|
||||
//Boost
|
||||
if (Input.GetButtonDown("Boost" + this.playerNumber) || aiInput[AiInputs.BOOST] > 0 && !this.lockBoost)
|
||||
@@ -99,5 +110,7 @@ public class PlayerController : MonoBehaviour
|
||||
this.forceZone.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
27
Assets/Scripts/test.cs
Normal file
27
Assets/Scripts/test.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class test : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//float horizontal = Input.GetAxis("Horizontal3");
|
||||
//float vertical = Input.GetAxis("Vertical3");
|
||||
//Vector3 direction = new Vector3(horizontal, 0, -vertical).normalized;
|
||||
//this.transform.rotation = Quaternion.LookRotation(Vector3.up, direction);
|
||||
|
||||
//this.transform.position += Vector3.forward * -10 * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/test.cs.meta
Normal file
11
Assets/Scripts/test.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 705f5d0d0e160ed4199e6efbf2af34d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user