13-08-2020, 09:51 AM
I noticed that grappling hook in the grappling hook demo does not seem to work if I tilt the camera. Hook does not connect to the objects on the scene.
Help Grappling hook with tilted camera
|
13-08-2020, 09:51 AM
I noticed that grappling hook in the grappling hook demo does not seem to work if I tilt the camera. Hook does not connect to the objects on the scene.
13-08-2020, 10:02 AM
(This post was last modified: 13-08-2020, 10:05 AM by josemendez.)
(13-08-2020, 09:51 AM)illustrator Wrote: I noticed that grappling hook in the grappling hook demo does not seem to work if I tilt the camera. Hook does not connect to the objects on the scene. Hi, I'm unable to reproduce this. Also, I don't see how camera placement/orientation could affect the physics simulation, as it is not taken into account at all...except for camera culling, which disables the simulation entirely when it is offscreen. To force the simulation to run even when not visible, enable "simulate when invisible" in the solver. Should be enabled by default though: http://obi.virtualmethodstudio.com/tutor...olver.html If this is not the cause of your issue, can you share a video of it?
13-08-2020, 08:39 PM
(13-08-2020, 10:02 AM)josemendez Wrote: Hi,Here is camera with no tilt. Every click gets hook attached and rope gets attached to same object "depth", I mean not on the back side or front side of the object. https://youtu.be/2harf1qQujU and here is camera with tilt. I'm constantly clicking and only some of the clicks get hook attached and also the rope attach position changes from backside of the object to the front side of the object when mouse click position goes higher. https://youtu.be/UAz45Tcqu-A What comes to my mind is that is the camera clipping plane or some other camera plane somehow affecting the calculations? See attachment: Red dots are mouse click positions. Green is world up axis. Two thin blue lines are ray casts. When mouse clicks go lower the hook attach point moves away and when clicks are higher the attach point moves towards camera until it does not attach at all because ray does not hit the object. When camera is not tilted all clicks are on the green line and all hooks attach. I think I should mention that I'm using Cinemachine to adjust the camera angle.
20-08-2020, 07:41 PM
I come back to this thread and try to give better examples. See images.
With tilted camera hook attaches to different points in z-depth if I click lower or higher (I don't click the object..). When camera is not tilted hook attaches always to same z-depth. // Get the mouse position in the scene, in the same XY plane as this object: Vector3 mouse = Input.mousePosition; mouse.z = transform.position.z - Camera.main.transform.position.z; Vector3 mouseInScene = Camera.main.ScreenToWorldPoint(mouse); Maybe I have misunderstood how this script should work when it calculates the attach point.. Does it affect the screen point calculations if user clicks on the "sky"?
20-08-2020, 08:28 PM
(This post was last modified: 20-08-2020, 08:30 PM by josemendez.)
Hi,
The raycast calculations assume a fully 2D scene. So the ray starts at the character, and is always contained inside the XY plane relative to the camera, as stated in the code comments. If you wanted a more general calculation that uses a world space XY plane (for a 2.5D game), you could calculate the actual intersection of the mouse ray and the XY plane (untested code), and use that as the endpoint to raycast from the character: Code: private void LaunchHook() This would allow you to place the camera anywhere in the scene. |
« Next Oldest | Next Newest »
|