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
1
Question by sid4 · Nov 20, 2016 at 04:03 PM · collider2d

How to only allow collision only on bottom side of 2d box collider Not top!

How to only allow collision only on bottom side of 2d box collider Not top! I only want players sword to be able to react if it hits the bottom side of the enemies 2d box collider as you know when colliders are set when you touch top sides or bottom they trigger
--so I only want the bottom to collide etc with players sword. so lets say if player swings sword on top of enemy 2d box collider , then it will not register , I only want to react if hits bottom of collider

2d game c#

Comment
Add comment · Show 1
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
avatar image sid4 · Nov 20, 2016 at 05:57 PM 0
Share

1 yes all 2d game and colliders

2 yes many enemys spawning

3 yes bottom of anywhere on the enemy (bottom)

1 enemy is spawned randomly and moves all over screen

2 so far yes 1 , 2d box collider on enemy and player sword has box collider on edge of sword.

3 no I may do that later but no, rite now no triggers anywhere

4 so far 1, 2d box collider on enemys

I have spawn scripts if needed but to keep things simple heres death script only

 using UnityEngine;
 using System.Collections;
 
 public class fishdedd : $$anonymous$$onoBehaviour {
  //Animation anim;
         public bool isDead = false;        //has the player collided with a wall?
 
          Animator anim;                    //reference to the animator component
 
 
     void Start()
         {
 
             anim = GetComponent<Animator> ();
 
         }
 
         void OnCollisionEnter2D(Collision2D other)
     {
 
         if (other.gameObject.tag == "Player") 
         {
             //Animation.Play("fishded");
             anim.Play("fishded");
             anim.SetTrigger("Die");
             //GetComponent<Animation>().Play ("fishded");
             Destroy (gameObject, 1.3f);
 
             isDead = true;
             GetComponent<AudioSource> ().Play ();
                 
         }
     }
             }

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MirkoSon · Oct 21, 2020 at 12:43 PM

You need to use the Platform Effector 2D as shown in this video: https://www.youtube.com/watch?v=M_kg7yjuhNg

Cheers.

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
avatar image
0

Answer by OutOfRam · Nov 27, 2016 at 10:09 AM

you cant.

Unity's collision system works by detecting whether an abject intersects an area(the colliders area) not its sides. what you are going to need to do is have multiple colliders on multiple game objects. Have the collider you want to receve damage when hit on an empty gameobject with a damage script attached to it.

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

80 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

finding valid targets in range 1 Answer

How to trigger functions like OnTriggerEnter2d and OnTriggerExit2d with raycasthit2d ? 1 Answer

Destroy GameObject or 2D collider does not work 1 Answer

I cant Disable Collider 1 Answer

Game hero sometimes can't move on connected blocks 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