Need Help (Script): UI reticle to RayCast gameObject > Transform gameObject to "hand" attached to FPS.
Hello all! I am a 3D modeler/Graphic Designer. I am fairly new to Unity and I have some coding experience (BUT not very much. Still newbie "C#"). Here is what I am trying to accomplish:
Use UI canvas with a graphic/image attached to a camera using the Canvas > Screen Space Render Mode
I have a the graphic (reticle) on that UI Canvas centered in the middle of the screen.
I want to use the "reticle" to point to objects in my 3D space
Capture that object and transform it to "my hand" (empty gameObject attached to my FPS Controller)
"hold" that picked up item while holding down a "button" (mouse or keyboard)
If "button" is released throw item the the direction of mouse sweep. (let it fly off in the last direction of the mouse before letting go (I have heard using a hinge or something like that. Don't know how.)
Also, turn gameObject TV on/off with "reticle" using VideoPlayer video texture.
If possible, open doors, flip switches, ect with "reticle" as well.
I have it working in Unity using mouseDown and Up, but my problem with using mouse it that it wont keep mouse locked in center of the screen using web. Since Microsoft dll controls the mouse it position the "grabbing" area where ever the mouse was last. I would really appreciate the help from all of those skilled programmers out there. Thank you in advanced for any help or direction!
@Steffen Franz I saw you had helped some other with their issue. Is there any way you could look $$anonymous$$e over?
One more thing. It doesn't have to be the UI, if that can't happen. I could use an empty gameObject to shoot from it's point of view as long as the mouse position is not an issue I am good. :) Thank you!
Do you help in C# as well. I was this particular problem, Need Help (Script): UI reticle to RayCast gameObject > Transform gameObject to "hand" attached to FPS.
but I don't know how. Thank you!
Answer by candlestickstudio · Feb 16, 2018 at 03:27 PM
This is not an Answer: Just an Update or clarification. I want to use the "reticle" as the projector of the graphicsCast or rayCast NOT where the mouse is located. Just want the "shot" or ray to come from the "reticle" position. That way the mouse location has no effect on my script just where the center of the screen is. :) Thank you!
UPDATE: So. I ended up finding the shooting game set up from Unity and used it
https://unity3d.com/learn/tutorials/projects/lets-try-assignments/lets-try-shooting-raycasts-article
Now, all i need now is for when it fires hold on to the object that was shot while holding down a "button" then fling it when I let go.
Your answer
Follow this Question
Related Questions
What to use instead of GameObject.Find and GetComponent 2 Answers
"cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.UI.Text' 2 Answers
Use InputField to be a search bar with a ScrollRect 0 Answers
Having multiple UNET errors that I believe are caused by unity itself. Am I doing something wrong? 1 Answer