Space Ship gameobject's Capsule Collider will not collide with walltrigger's Box Collider, please help
Ok so right now I am currently learning how to use Unity through Sams Teach Yourself Unity Game Development in 24 Hours. I just finished chapter 15, "Hour 15: Game 3: Captain Blaster." Right now I'm working on the end of chapter exercises to polish up the game and I'm completely stuck. This game is a 2D sapce shooter where you move along the bottom of the screen on the x-axis only. Around the camera view and scrolling background are walls called triggers that detect collision for the meteors to destroy the ones that make it off-screen. I want the ones on the left and right to stop my spaceship from moving out of bounds, but the problem is that when I try to collide with the triggers the spaceship just goes right through them. I'll provide pictures of my settings and scripts for both the triggers and spaceship.
using UnityEngine;
using System.Collections;
public class TriggerScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.tag == tag)
{
print("PLAYER");
//Destroy(other.gameObject);
}
else
{
print("METEOR");
}
}
}
using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour {
//player speed
public float speed = 10f;
//bullet prefab
public GameObject bullet;
//control script
public GameControlScript control;
//player can fire a bullet every half second
public float bulletThreshold = 0.5f;
float elapsedTime = 0;
// Use this for initialization
void Start () {}
// Update is called once per frame
void Update () {
//keeping track of time for bullet firing
elapsedTime += Time.deltaTime;
//move the player sideways
//if (transform.position.x < 7 && transform.position.x > -7)
//{
transform.Translate(Input.GetAxis("Horizontal") * speed * Time.deltaTime,
0f, 0f);
// }
//spacebar fires. The current setup calls this "Jump"
//this was left to avoid confusion
if (Input.GetButtonDown("Jump"))
{
//see if enough time has passed to fire a new bullet
if (elapsedTime > bulletThreshold)
{
//fire bullet at current position
//be sure the bullet is created in front of the player
//so they don't collide
Instantiate(bullet, new Vector3(transform.position.x+0.2f, transform.position.y + 1.2f,
-5f), Quaternion.identity);
Instantiate(bullet, new Vector3(transform.position.x-0.2f, transform.position.y + 1.2f,
-5f), Quaternion.identity);
//reset bullet firing timer
elapsedTime = 0f;
}
}
}
//if a meteor hits the player
void OnTriggerEnter(Collider other)
{
if (other.tag != tag)
{
Destroy(other.gameObject);
control.PlayerDied();
Destroy(this.gameObject);
}
}
}