Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Sipi2000 · Aug 06, 2014 at 10:14 AM · 2dcollisioncollision2dshootignorecollision

Ignore collision

I have a 2D top down tank game and my problem is if i shoot with the tank the bullet(Shell) collides with the tanks hull, the shooting is based on a cloning system which clones the Shell takes the transform and rotation and fly out of the tank, but like the shell the shell clone is colliding with the hull too and really weird things happen.Here is the script: using UnityEngine; using System.Collections;

 public class Shoot : MonoBehaviour {
     public Rigidbody2D projectile;
     public float canshoot = 1; // Can the tank shoot(1) or can't(0)
     public float _Reloadtime = 15;
     public float reloadleft;//Reload time left
     void Start(){
          reloadleft = _Reloadtime;//Sets reloadleft to 15secs
         }
     void Update() {
                 if (canshoot == 1)// The tank can shoot
                 if (Input.GetKey (KeyCode.Space)) {
                         Rigidbody2D clone;
                         clone = Instantiate (projectile, transform.position, transform.rotation) as Rigidbody2D;
                         clone.velocity = transform.TransformDirection (new Vector2 (0, 1 * 10));//Shooting...
                         canshoot = 0;//The tank can't shoot
                 }
                 if (canshoot == 0)
                         reloadleft -= Time.deltaTime;//Reloading...
                 if (reloadleft <= 0) {
                         canshoot = 1;//Reloaded the tank can shoot again
                         reloadleft = _Reloadtime;//Reloadtime is 15secs again
                 }
 
     }
 }
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 AuraCS · Aug 06, 2014 at 02:47 PM

I guess that you want a way to ignore some specific collisions. Maybe you can try this:

Physics.IgnoreCollision(collider1, collider2, ignore);

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Find cardinal direction of collision based on 2D Cartesian coordinates 1 Answer

2D Triggers and Collisions not working as expected. 2 Answers

How would I move an object towards the mouse but not stick to it. 1 Answer

Unity2D collision problem 3 Answers

Check if a Collider2D is hit by a Trigger Collider2D 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