- Home /
How do I stop my player from going through the platform?
I am just a beginner with Unity so please, forgive me for asking stupid questions. I have to make a game in Unity (3d, infinite runner type) where I have a player which is a fish. I have created the "seabed" from a plane and I have imported my character and added a movement script to it (transform.translate). My problem is that the fish goes through the seabed. I tried adding box colliders for both and it ended so that the when hitting the seabed the fish would start "flying" and spinning and the "seabed" would collapse. I have no idea how to fix this issue.
I am also supposed to add the water so all hints for that are welcome too.,I am a very beginner with Unity so, forgive me for being stupid. I have to make a game where a fish is swimming in the sea. My problem is that I have imported the fish (my player) character and I have made a "seabed" from plane. The fish has a movement script (transform.translate). When I move the fish, it will go through the "seabed". I tried adding colliders and then, hitting the seabed made the fish start "flying" and spinning in the scene. I have no idea how to fix this.
I have not yet created the water to the scene so also all good tips for that are welcome.
Answer by RadonRaph · Nov 02, 2019 at 01:05 PM
Hello @Tkala19, if you are a beginner a suggested you to watch the beginners tutorial on Unity, it will be much more faster than waiting our response. There is mutilple way to detect colission in Unity:
The easyiest way is to add an rigibody componenent to both your fish and your seadbed. The seabed's rigidbody need to be statics. Rigidbody works with collider. You will have collisions gravity and all physics like bouciness etc.
One way wich use the transform.translate is to use raycast (Physics.Raycast()) to detect colliders in a certain direction :)
You will have more information here:
https://docs.unity3d.com/Manual/class-Rigidbody.html https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
Hope that help ! Raph
Your answer
Follow this Question
Related Questions
Rigidbody gameobject falls through plane 1 Answer
OnMouseDown not firing if character isn't touching ground 0 Answers
Colliders going through Colliders? 1 Answer
Unity3D Rigidbodies acts like objects is elastic and falling inside eachother 0 Answers
game object falling through plane when adding rigid body component 1 Answer