Skip to content
Snippets Groups Projects
Commit a7912688 authored by Sturmwolke's avatar Sturmwolke
Browse files

Merge branch 'bugfix/forcepush'

# Conflicts:
#	Assets/Scripts/Force Scripts/forcePushScript.cs
parents 62266c89 939e2c48
No related branches found
No related tags found
No related merge requests found
......@@ -126,8 +126,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10.27, y: 2.51, z: -26.15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 6457676831594224578}
m_Children: [{fileID: 6457676831594224578}]
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......
......@@ -9,13 +9,16 @@ public class forcePushScript : MonoBehaviour
GameObject player;
// TODO: change direction v3 to input
void Start()
void Start ()
{
/*
player = GameObject.FindWithTag("Player");
direction = player.transform.forward;
rb.velocity = direction * 100;
*/
rb.velocity = direction * 10;
StartCoroutine("KillAfterTime");
}
......@@ -26,30 +29,29 @@ public class forcePushScript : MonoBehaviour
Destroy(gameObject);
}
private void OnCollisionEnter (Collision collision)
private void OnTriggerEnter (Collider collider)
{
if (collision.gameObject == null){
return;
}
// don't know if this is needed, ignores collision with player
if (collision.gameObject.tag == "Player")
Rigidbody bodyOfCollider = collider.gameObject.GetComponent<Rigidbody>();
if (bodyOfCollider)
{
print(gameObject.GetComponent<Collider>());
print(collision.gameObject.GetComponent<Collider>());
Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), collision.gameObject.GetComponent<Collider>());
bodyOfCollider.AddForce(direction * 3000);
}
// don't know if this is needed, ignores collision with player
if (collider.tag == "Player")
{
Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), collider.GetComponent<Collider>());
}
//or children of the player gameObject
if (collision.gameObject.transform.root.gameObject.tag == "Player"){
Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), collision.gameObject.GetComponent<Collider>());
if (collider.transform.root.gameObject.tag == "Player"){
Physics.IgnoreCollision(gameObject.GetComponent<Collider>(), collider.GetComponent<Collider>());
}
// kill on wall
if (collision.collider.GetType() == typeof(MeshCollider))
if (collider.GetType() == typeof(MeshCollider))
{
Destroy(gameObject);
}
}
}
......@@ -5,17 +5,11 @@ using UnityEngine;
public class forcePushSpawn : MonoBehaviour
{
public GameObject forcePush;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// TODO: change input to controller
if (Input.GetKeyDown("space"))
if (Input.GetKeyDown(KeyCode.F))
{
Instantiate(forcePush, transform.position, transform.rotation);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment