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 rjs_chipmunk · Dec 13, 2016 at 10:35 AM · c#collisionssimple

Im tring to get a collision to output while allowing the objects to overlap Csharp, any ideas appreciated.

public float PlatformSpeed = 0.04f;

 void OnCollisionEnter2D(Collision2D col) {
     
     if (col.collider.gameObject.tag == "Player")

         GameObject.Find("Player").transform.Translate (PlatformSpeed, 0, 0);

This is the collison script im working with, in a sense it works, atleast it runs and it does move my player, but only if the platform hits my player first, if i jump onto the platform i just sorta sit by the side of the object, the only way i know to allow them to overlap is by changing one to 'is trigger' but then it doesnt output, been stuck for a while now so any and all help will be much appreciated.

Hopefully you see what im trying to do, thanks for taking a look :)

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 sumitb_mdi · Dec 13, 2016 at 02:55 PM

Yes you are correct, that if you want them to overlap, you need to change those colliders to Trigger Colliders. After that all you need to do is change your method From :

 void OnCollisionEnter2D(Collision2D col)

To :

 void OnTriggerEnter2D(Collider2D other) { 
      //Your logic here with other.gameObject.
 }
Comment
Add comment · Show 4 · 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 rjs_chipmunk · Dec 13, 2016 at 05:41 PM 0
Share

ok, well firstly, thanks for the reply, appreciate it!

But i tried what you wrote me, and while the player can now jump onto my platform, he doesnt move... i do want to check, should the trigger be the platform or the player because making the player the trigger will mess up loads of other scripts.

Also just for reference the script is to be attached to the platform as i have multiple platforms all moving at different speeds.

Just to make sure that i got it right, heres my newly modified script...

 public float PlatformSpeed = 0.04f;

 void OnTriggerEnter2D(Collision2D other) {
     
     if (other.collider.gameObject.tag == "Player")

     GameObject.Find("Player(Frog)").transform.Translate (PlatformSpeed, 0, 0);
     print ("HIT!");



      }

Thanks again!

avatar image rjs_chipmunk · Dec 13, 2016 at 05:47 PM 0
Share

Also, sorry if ive done something obiously dumb here, im very new to all this

avatar image sumitb_mdi rjs_chipmunk · Dec 13, 2016 at 07:00 PM 0
Share

Can't get what you are trying to accomplish here. If you want I can help you over Skype with these scripts, that would be faster ins$$anonymous$$d of guessing what you are trying. (SkypeId: sumitb.mdi)

avatar image rjs_chipmunk sumitb_mdi · Dec 14, 2016 at 09:58 PM 0
Share

To be honest, i appreciate you trying to help me but im a bit funny about adding random people on skype, even for my own benefit. but if this helps im basically re-creating frogger, and im trying to make it so that the frog can jump onto the logs and move at the same speed as the logs.

in theory, what im trying to achive witht the code i have is...

if player (Frog) is touching the log then move the player at "platformspeed"

appreciate you helping me all the same thanks :)

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

276 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 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 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 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

How to learn loading/pressure/compression on a 2D body? 0 Answers

How to Change players Desktop Background C#? 1 Answer

Cant Get Simple Boolean Statement to Work! 1 Answer

Simple Camera Switch Using C# 3 Answers

2D Object Spawn Lag 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