Questions tagged [raycasting]

A technique for using rays to determine points of intersection. Often used in lighting simulation.

0
votes
0answers
20 views

Whats the most efficient way to implement precise ray picking for scenes with large meshes?

I'm wondering how to implement ray picking in the most efficient way for scenes with very large meshes ( > 1 million faces)? Right now I'm using BulletSharp physics wrapper with TriangleMesh which ...
0
votes
0answers
38 views

Unity Raycasting only hitting mesh colliders from particular directions

I have a game which involves clicking to select some objects. Each of the objects has a mesh collider attached to it so that objects can be clicked, handled by the following: ...
0
votes
0answers
38 views

C++ Mouse picking for ray to plane intersection

I'm making a C++/OpenGL application (decidedly without GLM), and I'd like to understand how to create a ray from the camera eye to the mouse pointer, as well as detect an intersection point from the ...
1
vote
2answers
143 views

Efficient collision detection of sphere with wall

I'm building a first-person game where up till now the player has been represented as a dimensionless point; this makes collision detection really easy, as I can just cast a ray along their velocity ...
0
votes
0answers
134 views

Raycast collision Detection different results?

So I'm trying to make a collision detection system for a kinematic rigidbody for a gameobject but for some reason the results in which the gameobject stop is always different. I tried missing around ...
0
votes
0answers
37 views

Problem with repeating objects in array when already in the array

When the player move forward then paint is instantiate and stored in the array, even if the paint is already in the array it will again be stored in the array. But I don't want to repeat any paint in ...
0
votes
1answer
82 views

How to detect when the player has filled a shape?

In my game, the player is presented with a plane containing obstacles (orange / blue) and regions of empty space (white). The player moves their green cube around the empty space, which instantiates ...
1
vote
0answers
34 views

MousePicking in LWJGL - How to do it?

I have been working on a mouse picker for a scene in 3d for a client, and been having issues implementing a proper mouse pick. His application does not use a camera, and I am trying to get the ray ...
0
votes
1answer
30 views

How to check if a specific instance of a prefab is pressed?

This one is hard to explain, so I'll show the code first - ...
0
votes
0answers
13 views

How to move cube touch position and when hit my collider then stop my cube using raycast? [duplicate]

cube will be move but when hit my collider not stop my cube,used in program raycasting Code: public class MoveCube : MonoBehaviour { float speed = 0.5f; public Animator anim; ...
0
votes
1answer
27 views

Raycasting from an object to the center of the screen (crosshair) without clipping through objects

Am trying to learn about Raycasting, and I thought I would start with something simple, and that was a laser that would come out of an object (think laser pointer in your hand) and always go to the ...
0
votes
2answers
43 views

Perform intersection (horizontal and vertical) checking in raycasting

I want to check the horizontal and vertical intersections on my raycasting view, and I can't exactly understand what is ALPHA using this drawing source : https://www.permadi.com/tutorial/raycast/...
0
votes
1answer
39 views

Raycasting center of camera is not working: why?

In my game i'm using Unity First Person controller. I check every second what I am looking with the following code: ...
0
votes
1answer
87 views

Understanding the rendering of the raycasting on flat screen

I have a misunderstanding of the raycasting formulas on flat screen because my rendering is not what I expected, this is some parts of the code to show my projection formulas that I wrote by myself ...
1
vote
1answer
71 views

Unity3D Raycasting in Start behaves uncorrectly, but works correctly in Update?

I have this method, which just raycasts at a position downwards, and checks what tile is there, if there is one: ...
0
votes
1answer
48 views

Finding the on-screen height of straight walls in raycasting rendering

I have an issue to find the correct height of walls to make them straight in raycasting rendering. This is how I calculate the height of the wall which is h_seen: ...
0
votes
1answer
57 views

Rendering a raycasting view

I am trying to reproduce the raycasting of the game Wolf3D. I read this tutorial, but I am struggling to understand how to code the intersection between the rays and the walls by using angles and ...
1
vote
1answer
69 views

What are some gameplay cases where knowing the Z as a result of the raycasting is useful in a 2D setting?

The context is an 3D engine with a 2.5D level format. Like a roller coaster tycoon level, with some other level features added, and layers removed. For example the tile functions have the following ...
0
votes
1answer
29 views

Unity AudioSource.PlayClipAtPoint - controlling attenuation

New developer here, looking to do some raycasting and controlling audio positioning in 3D space based on the raycasts interactions with other objects. I've got the raycast 'casting' and able to report ...
1
vote
1answer
70 views

Rigidbody & Ray alternative or optimization

I am creating an AI that moves around to certain points, but should interact with ais or objects seen. The ai should find other ai to comunicate or look for objects on the ground. It works with all ...
0
votes
2answers
57 views

In 2D, how can I improve character rotation using raycasts when dealing with sharp/convex edges?

Edit: After making some edits to my polygon collider (based on @Alex F's suggestion), I can indeed confirm that sharp, convex corners are causing the buggy ...
1
vote
1answer
55 views

Unity SphereCast HitInfo Give me an interpolation of the normal surface?

I'm doing a SphereCast for a GroundCheck of a player. I have my Raycast hitInfo, and here in the picture at the left, I Debug.drawRay in black the direction of the hitInfo.normal every frame It seems ...
0
votes
0answers
43 views

How to implement Microwave Signals in Unity?

I need to implement microwave signals for object detection in Unity. I know there are raycast sensors in Unity, but can microwave signals be simulated or can a proxy of microwave signals be created ...
3
votes
1answer
86 views

Why does my collider rotate correctly on a slope only when a ray is cast directly from its center?

Edit: This answer might also be helpful to those who come across this question. I've been messing around with raycast collisions and slopes, but am having an issue when trying to get my collider to ...
0
votes
0answers
25 views

Check gap in 3d environnement

I am in a 3d environnement, when I jump, i'm calculating the hitPoint of the end jump. I want to know when I jump, if there is a GAP between my initial point, and the end point. But I don't want to ...
2
votes
1answer
107 views

How to detect when the mouse is over a particular enemy collider, without falsely selecting bullet colliders?

I have an enemy shooting around. My game mechanic involves hovering over the enemy with the mouse to drain its health. While the enemy is moving, you need to follow it with your mouse. If you don't ...
0
votes
1answer
57 views

Raycaster calculation question

I am following this tutorial https://lodev.org/cgtutor/raycasting.html When deriving deltaDistX geometrically you get, with Pythagoras, the formula "sqrt(1 + (rayDirY * rayDirY) / (rayDirX * ...
0
votes
2answers
78 views

Difference between reflection mapping and raytracing

Both methods involve casting a ray unto the reflecting object. It will be reflected. In reflection mapping - the intersection of this reflected ray with the environment map (texture) will yield the ...
0
votes
1answer
67 views

Can't figure out why my mouse picking code doesn't work

I am trying to create code to check for intersections between bounding spheres and the mouse. I get a mouse ray but it doesnt seem to point in the direction you think it should Attached is a ...
0
votes
0answers
14 views

rayTest for cutted by stencil objects

I have red rectangle based on which I am cutting (using opengl stencil) all of the green rectangles, like shown in the following screenshots a) before cut b) after cut When I run rayTest(bullet ...
1
vote
2answers
59 views

How can I check if the mouse hits a quad in 3d, and where it hits it?

I have a sketch that produces the following: ...
0
votes
0answers
25 views

The Raycasted plane (surface) ascend or descend with my camera

I would like to be able to draw an infinite plane in order to do multiple FX (such as a fog floor) later. I used the following shader that works except that the plane (surface) seems to follow my ...
0
votes
1answer
61 views

Raycast does not go to target position

There is a part in my script where I need to make a raycast check from my gun's muzzle to the enemy. This enemy could be anywhere around player. I found my ray is not connecting to the target ...
2
votes
3answers
152 views

Get closest point on box to line

Eventually this problem will be 3D, so I would like a solution that works in 3D. My player is looking forwards. There is an axis-aligned box on the screen (FOV is guaranteed to be 90, so boxes behind ...
1
vote
4answers
260 views

How can I convert Physics2D.Raycast to Physics2D.BoxCast to yield the same results?

This question has been updated to better reflect my current issue, and some of the progress made while solving it. I've been working on a 2D character controller that uses raycasting to detect ...
0
votes
1answer
103 views

How is raycasting implemented

I know what it's used for, I know what it does. What I am essentially asking is what is the math/code behind how it works? I'm aware that any custom implementation would likely be slower than an ...
0
votes
1answer
54 views

How would I properly flip a character when they reach the edge of a ground object in Unity 2D?

The idea here is that the raycast shoots downwards from an empty game object and when it detects that there is no ground below it the character should bounce back and walk the other way. When I get to ...
0
votes
1answer
54 views

Unity: How many Raycasts per Sphere Collider?

I understand that a simple sphere collider in Unity is a raycast in all directions with a certain length. How many Raycast events does a sphere collider trigger? At what degree increments are the rays ...
1
vote
1answer
181 views

Noise when using SSLR (Screen Space Local Reflections)

When I tried to apply reflections to my scene, I ran into the problem of noise: My fragment shader code: ...
1
vote
1answer
83 views

Pathfinding to Get In Attack Range with “Transparent” Tiles

Currently I'm using A* and a raycasting algorithm to determine the path an entity (Player) should take to get close enough to the enemy (Enemy). The player has an attack range (it's illustrated around ...
0
votes
2answers
57 views

Bullet spread changes depending on the camera direction

I'm working on an FPS game. I want to make a little bit of difference in shooting direction, only on the horizontal axis. To do this, I wrote this code: ...
0
votes
1answer
425 views

Why is my spherecast returning an incorrect hit on mesh collider? (Unity)

I have a mesh collider that is largely a flat plane facing up. Any SphereCast against that surface should return a normal of Vector3(0, 1, 0), but that isn't always happening. When near an edge on the ...
0
votes
0answers
24 views

Only do 1 SphereCastAll in Unity3D? [duplicate]

I just want to make one SphereCastAll with a center and a radius. I don't want unnecessary sweeping in a desired direction with a desired length. How is this achievable? My solution is pretty ...
0
votes
0answers
9 views

Unity3D: Multiple OnTriggerEnters are called before the first one could finish and destroy the object

I'm working on a projectile which explodes when it reaches a destructible object and damages its voxels. (The projectile is a trigger) But the problem is that I use raycasting in ...
0
votes
1answer
155 views

Determine if ray hits an edge of a model in Unity 3D

How can i determine if a ray was hitting an edge of a mesh? The figure below shows what I want to achieve: Any ideas?
0
votes
1answer
440 views

How to raycast in MonoGame 2D?

Currently I am using a Ray class that I built myself. The following is for brevity. ...
0
votes
1answer
37 views

Spherecast - enabling MeshRenderer of selector target around prefabbed object once hit and disabling Meshrenderer when not hit anymore

I have an interesting problem - I have been looking up for solutions on this but I think there is something I am missing and I require a little more knowledge. I have a scene and the scene has an ...
1
vote
1answer
51 views

How to select two different instances in Unity C#

I have 2 Balls, 2 Nodes, and 1 Hand. I can pick up a ball, send it to a Node, grab it, put it on another Node, but I can't grab any other balls. The problem is that the Ball is defined publicly in ...
3
votes
1answer
41 views

Isolate UI elements from 3D scene

this might seem like a silly question but I'm raycasting on specific objects (Targets) in a scene and zooming in on them but i also have a few UI elements (buttons, toggles...) on the side of the ...
0
votes
1answer
149 views

Unity 2D Tap to shoot at mouse position on android device

Hello everyone i am really stuck at the moment and would appreciate any help if possible. I have my game where i move the player up and down with 2 buttons on the bottom left of screenshot. I also ...