I'm trying to detect when the user click on a plane in C#. I tryed OnMouseDown() but it has no effect.
According to some topics on the web, the object must have a collider, but my plane has one.
I also found topics talking about raycast, but I must admit I don't really understand what it is and what it does. Could someone lead me to a good and (relatively) simple exemple that explains well how to do what I would like to do?
Thanks, have a good day
From my previous comment, the plane was marked as Trigger.
"This function is called on Colliders marked as Trigger if and only if Physics.queriesHitTriggers is true." from here.
Related
I'm just wondering how to make shots in my game more realistic. I mean there are two main ways in implementing shots. First: throw a small projectile and let it detect collisions. Second: use raycast. But in real world (and apparently I noticed this in PUBG) bullets fly really quick but not immediately. Here is why you should aim near your target if it's far away from you to hit it. Because if you aim right where it is it will move and your bullet will miss the target.
I'm just curious if any of you, guys have a nice solution to this problem. Also I wish to find a way to use raycast not every frame. In such things like detecting if you will actually hit the wall when shooting. If you have any good ideas how to implement spread and recoil for different types of weapons I will be happy to read them.
Blue point is bullet point of frame. and in very frame send a new raycast to check cross any human. like red line in this picture.
and bullet path use unity built-in Physics system to do it.
In Godot, if a 3D raycast isn't hitting where you'd expect it to hit, how do you debug it? I'm looking for some way to draw the ray (or a line that follows the ray), problem is, I can't find anything in the docs, so your help is much appreciated.
Sadly there is no easy way to accomplish a "Line3D" in Godot (There are some free assets and third party solutions for that).
However, being for debug purposes, all you have to do is enable "Visible Collision Shapes" on the "Debug" menu.
A common use of RayCast is to do them from the Camera. In which case they probably look like a point. And if you are also updating them every frame, they would follow the camera continuing to look like a point.
In that case, I suggest to duplicate or stop updating the RayCast you want to inspect on a key press. Said another way: Check if the user pressed a key, and when they do, either duplicate or stop updating the RayCast. Then you can move around and see the RayCast from an angle where it does not look like a point.
I don't get how to make the camera shake when my player collides with the obstacle.
I can suggest you a lot of different ways to do it, depending on what you trying to do,
and what you already did...
Like, I can think you just started learning Unity and suggest you to use OnTrigger methods to detect collision with your player, then implement a method to apply a noise to your camera position.. But, is your cam a ThirdPerson one? FirstPerson? Fixed? 2D topdown? 2D platform? 2,5D?
Do you get it? Is important to follow the guide to Ask a Question... Try to answer these questions, saying what you already did, what you already tried and I'm sure you'll find help.
I am trying to make a TopTrupms Card Game. I ended up with the cards and the Buttons of one player on the Stage. The second one is at the side. Because i want make a multiplayer game i have no concept how to move forward. Should i make the second Player also playable and than try to make it multiplayer or should i try to make it multiplayer now with the currentcard? (Code) I cant understand how it is possible to show different cards to different players at the same stage in multiplayer and i cant find a tutorial that shows this. Its always about 3d stuff where all player see the same things on the same stage. So i dont know which way to go. Please can anyone move me in the right direction, give me a hint or tell me how i should exactly do it!!! I dont know how to describe my project correct but i try. I made two different lists with shuffled cards and their attributes in it, parsed from a txt file. all the numbers are linked to different objects in the game that are a background image and different Buttons to choose the Value you wanna play against the card of the other player. Till now the second player can not vote and the first player is always at the turn. should i
Here is the Code and sorry for bad anotations, i am a absolut noob on this and just learning the basics of Unity and C# but i cant wrap my head around this Topic for any reason...
Please give me a hint!
It seems your question is more design based.
Read about the Entity-Component design pattern.
https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system
Basically think of an implementation like so, in your game you will have a list of Entities. Each Frame these entities will all update.
In the update function of your entities your entities will update all their components.
Your Player entities will have input components, but which input component will be decided at run time, either NetworkedInput, LocalInput, AiInput etc.
Got it!
The anwser is Network.isClient to make it multiplayer right away with the currentcard.
This is the way how i will do it. I jurst write every functions of the currentcard inside this if and els function for both players.
It should be the anwser i was searching for.
Thanks for the hints. They are very valuable for me.
#Ed Plunkett I hope i can present my next question more concrete and more on the point. It was hard for me to get a basic understanding of networking programming and i am so happy i got it now. Its always so easy afterwards.
I'm working on a simple Paddle Game project nowadays. In the begining, everything's looking good. But, when I complete my level design and publish my game, I see gameobjects in my scene are moving so slow. I think, I pass over the Unity3D's physics limit. If I try some Math instead of Unity3D's Colider, I can finish my first project. (I tried to use Separating Axis Theorem, but I can't handle x and y coordinates on Unity3D.)
I need your help. Thanks a lot for your time. (And If I can handle this problem, I will share my project on the internet, for beginner people like me.)
In my project, I achieved this simulation with using BoxColider, but because of Unity3D physics limit, I don't want to use colider in my project.
You can't not detect collision. I'd recommend using Unity's colliders for that, since they're really not bad. The first thing I notice is that in your first simulation, you have 4 box colliders, when instead you should just have one. Use the OnCollisionEnter event (on the spheres) to reflect them off your box.