# Tag Info

1

The cheapest (but not necessarily very flexible) solution would be to duplicate the shader code in your C# script. When the player clicks, fire a ray through the mouse position. Capture the RaycastHit struct, and it will give you the world position and texture coordinates of the point directly under the mouse. (If you've displaced your sphere out along the ...

0

Well I finally figured out the issue with some help from here and Reddit. Basically I was trying to send the raycast from the model's (the child) forward and that was the wrong forward. So I changed the third (2nd) line of code in the update statement to Ray ray = new Ray(Player.transform.position, Player.transform.forward);. This basically makes it so that ...

1

A Couple things to check: 1) Transform.forward may not be the direction you actually want to shoot the ray. For example if this is a first-person game, the direction the PhysGun is facing (transform.forward) may be totally different than where the camera is looking, and in that case you would probably want to shoot the ray from the camera. 2) Have you ...

2

A lot of calculations can be simplified by turning this into a 2D problem, and you can do that by casting your ray along a single axis -- x, y, or z. For a given V = { Vx, Vy, Vz }, if we cast our ray along the z axis, we're effectively just checking which triangles intersect the 2D point V2 = { Vx, Vy } (projected into 2D by removing the z component). From ...

0

I am not aware of an easy way of doing this. The way I'd do this is the following: Determine XY position of click on texture (x = 0..1, y = 0..1) How to do this depends on where you use it, but will likely require raycasting. Go to the camera that sends the image to the texture. Assuming the camera uses perspective projection: Calculate the 3D ...

1

Rigidbody Contraints is a class to use for the rigidbody. In your case, instead of using hit.transform. = RigidbodyConstraints.FreezeRotation;, I would replace that with hit.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;I see that you have tried to set a Rigidbody class on a Transform. Rigidbody constraints take a ...

Top 50 recent answers are included