Sorry for the title error. I was typing to fast.
I have made a couple simple games with Unity and I’m now working on a game where I want a couple hundred spheres in a fixed 3D environment. My idea is to make a box consisting of hundreds of tiny floating spheres that when one sphere (the player’s sphere) touches turns red. I have a hard time finding out how to do that. I have done very minimal scripting before, (my primary lang. is C++) I have been looking through the manual and the wiki and I need to know how to do three things.
#1 how do I set up a box full of tiny floating objects that are NOT connected to each other. (Think atoms)
#2 How do I make objects invisible accept when they are touched by an object?
#How do I make an object that can go through anything?
I posted here first before doing more research because I’ve always gotten such helpful advice. If I find the answers I’ll take the question down. Any comments or resources (especially scripting resources) would be great and much appreciated.
Thank You.
You’ll want to be working with Unity’s physics engine (standard tutorial here). To break it down…
You’ll likely want to make a “controller/manager” script for spawning your spheres. Make a prefab for your sphere so you can reuse it, then have an empty object script that generates them at the locations you want.
Look in that tutorial specifically at colliders, and using colliders as triggers. You should learn how to change a property using the OnTriggerEnter method.
In the engine, rigidbodies that are kinematic won’t participate in normal unity physics. So if you normally have gravity or collisions, they won’t apply. You will have to animate them yourself then (assuming you want them to move).
Edits:
I’d also make sure you understand the physics part (esp kinematic objects and triggers), before worrying about the scripting part, before worrying about making them into pretty spheres. If you can stick a bunch of cubes on the screen and get them to perform an action when they touch, you’re most of the way there!
If you start getting into more complex scripting, I find this to be a great resource for thinking about how to structure your game. It’s never too early to be thinking about code design patterns! For example, if you want to make lots of your spheres, and if they often spawn/despawn, check out the flyweight pattern, which can really improve performance in those situations.
There are some great language-specific resources out there. If you’re coming from C++, there are great language tutorials on both javascript and c#, occasionally with specifics for making the transition.