A rendering technique to create a 3D perspective in a 2D map
Questions tagged [raycasting]
1193 questions
3
votes
2 answers
Moving GameObject with RayCast hit position causing object to move towards Raycast start position
I have RayCast represented by a LineRenderer in Unity, so it looks like a laser. I want this laser to move objects it collides with so that the object follows the hit.point of the Raycast hit.
My code doesn't work, because I move these GameObjects…

karamazovbros
- 950
- 1
- 11
- 40
3
votes
1 answer
How can Raycast interact with Unity's Canvas UI elements?
I created a Raycast that shoots from an object(not main camera) and I want it to hit UI elements. Example below.
Example
UI outlined in orange, big grey plane is a test object, red head is placed upon user's head and green is DrawRay of my raycast…

Denis Kulikov
- 71
- 1
- 6
3
votes
1 answer
Why Collider2D.Raycast & Collider.Raycast are so different?
Collider.Raycast -> Casts a Ray that ignores all Colliders except this one.
Collider2D.Raycast -> Casts a ray into the scene starting at the collider position ignoring the collider itself.
I want to use it like Collider.Raycast where it "ignore all…

FunFair
- 191
- 1
- 12
3
votes
0 answers
Water refraction causing odd effects, and wont go above 1.0
I've been trying to generate water effects via fragment shader in shader toy. Right now I'm trying to use octave ridge noise multifractals in order to generate a water-like surface. So far, this works fine. The next step I wanted to take was…

Krupip
- 4,404
- 2
- 32
- 54
3
votes
2 answers
Unity2D/C#: How do I make a raycast ignore its first collision?
One of the features of the raycast controller for my platformer game is that the player can jump down through 1-way platforms. This works nicely, but I wanted to add additional functionality where the player will only be able to jump down if the…

Ginger and Lavender
- 436
- 1
- 8
- 21
3
votes
1 answer
How to properly rotate the raycaster according to the object position and rotation in three.js
I have 8 raycasters from the Object3D to different direction for the collision detection. I want to rotate the direction they were pointing according to the object rotation. I have followed the solution from here
The raycaster start rotating but in…

Bipin Manandhar
- 105
- 11
3
votes
1 answer
Calculate distance between Mesh Edges
I've the point of origin readily available where my mouse is on screen like so,
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Now imagine a cube. Anywhere you click on this cube, a line is drawn from the edge clicked on,…

jtth
- 876
- 1
- 12
- 40
3
votes
1 answer
Unity: Raycast in Editor Mode does not work
I am trying to render the trajectory path of the movement of the ball in my game, all in Editor mode.
I believe that this will help my team in creating levels, as it will require less testing while prototyping.
Here is my code:
using…

Kokolo
- 250
- 2
- 12
3
votes
2 answers
How to tween a camera to an object in three.js?
I've created some objects in my scene, and set up raycasting/tweening code so that whenever I click on an object, the object animates directly to the position and rotation of the camera.
This is my code for raycasting/tweening the object:
function…

qbuffer
- 383
- 4
- 14
3
votes
0 answers
Raycasting from a specific point
I need to do a very basic version of ray-casting, however I need to do this about 10^7 times. What I need to do is to shoot rays from some point in a specific angular pattern and detect the first intersection with an object. That's basically it.
I…

ZappaZ
- 95
- 1
- 6
3
votes
1 answer
Threejs BufferGeomatry raycast not hitting
I'm creating a subdivided plane buffer geometry to improve performance from the plain plane geometry, but my raycast isn't hitting the PlaneBufferGeometry.
I'm getting this error in the console that I think it probably the…

Keith M
- 1,199
- 2
- 18
- 38
3
votes
2 answers
Three.js select object with camera, no mouse
in a Three.js app I want to get the object that the perspective camera is pointing at and to do that I read the raycaster docs.
All the docs that I found talk about doind raycasting with camera and a Vector2 from the mouse coordinates, but I don't…

ascallonisi
- 871
- 1
- 11
- 20
3
votes
1 answer
How can I efficiently implement raycasting through a 2D mesh?
I'm implementing a nav mesh pathfinding system and I need to be able to raycast between two points in the mesh and get a list of all edges crossed by the ray. Obviously I'll need to be able to test for individual line intersections, but I expect…

SilentSin
- 1,026
- 9
- 18
3
votes
0 answers
Unity 5: Raycast on non-convex Mesh Collider
I'm using this code to raycast on objects and fire events:
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
{
var ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
if…

ThomasSquall
- 644
- 6
- 21
3
votes
3 answers
How to move unity prefab to mouse click position?
I create an unity3d application that loads prefab and move it. I can load a cube prefab using world coordinate.I want to move this object to mouse click position. To do this work, I use below code. My object doesn't move anywhere.
public…

zakjma
- 2,030
- 12
- 40
- 81