Switch scene on collsion C#
I haven't been able to find anywhere that explains this in C#. What code should I use so that when the player object collides with my object it will switch the scene? All the tutorials I've seen don't work for me.
Answer by Dave-Carlile · Oct 20, 2015 at 11:56 AM
Break it down into individual steps:
Set up colliders and get collision detection working
Learn how to load a level
Combine the two - when a collision is detected, load a level.
There are thousands of examples of each of these things. There are tutorials in the Learn section above that go over these things.
Okay I will try some different methods of collision. It may be that the one I am using is meant for a different purpose or not setup correctly.
$$anonymous$$ake sure you have rigidbodies and colliders and such - those are things commonly forgotten. $$anonymous$$ake sure the On*Enter methods are spelled correctly and have the right case. It's often helpful to start with a new empty scene and get things working with just the bare $$anonymous$$imum... e.g. just print out a message when two cubes collide. Work through getting that working and you'll gain a decent understanding of what you have to do in your real scene.
Okay I will try that. $$anonymous$$y main character is a ball much like that of the roll a ball tutorial. I have tweaked it a bit though. I will see if I can get it to work.
And nice job taking the time to work through the things on your own. Breaking things down into small pieces and figuring out each of those is a valuable skill.
Your answer
Follow this Question
Related Questions
Why does my script and collider2D automatically deactivate after reloading the scene? 0 Answers
Need Help with a Level Reloading Script (c#) 1 Answer
CapsuleCollider check if grounded 1 Answer
How to Make A Character Stop At Wall? 0 Answers
problem with tilemap collider and composite collider 1 Answer