Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by willmcckill · Apr 25, 2016 at 04:52 PM · collisioncolliderboxproblem during runtimecapsule

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. alt text

alt text

 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);
         }
     }
 
 
 }
triggersettings.jpg (305.8 kB)
spaceshipsettings.jpg (242.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by willmcckill · Apr 25, 2016 at 06:30 PM

anybody??

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

69 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Collision to change Pitch 0 Answers

How can i restart a script on collision ? 1 Answer

Unity 2D colliders not triggering,Unity 2D collider not triggering 0 Answers

How to snap a placeable object on wall & move on to other walls of a room? 0 Answers

How to detect collision of two moving characters? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges