Questions tagged [raycasting]
A technique for using rays to determine points of intersection. Often used in lighting simulation.
455 questions
0
votes
0
answers
44
views
Raycast DDA: Wall rendering and floor rendering out of sync
I come for theory help with a classic raycast algorithm (currently, based on DDA). The problem is not with the algorithm itself, but with the floor rendering code.
I left the code of my raycast render ...
1
vote
1
answer
44
views
Why is my raycast not working?
I'm trying to ray-cast mouse clicks to the surface of a sphere (from which point, I'm going to get the coordinates of the vertex of the sphere's mesh that are closest to the click). The following ...
0
votes
0
answers
52
views
Issue raycasting when direction vector nears zero in x and z axis
I am working on a voxel game right now in OpenGL and working on implementing raycasting so I can pick blocks in my world. So far what I have created works quite well except for when the x or z axis ...
0
votes
1
answer
44
views
How to filter/ignore child objects from an ML Agents RayPerceptionSensor in 3D?
I am making a snake AI with Unity ML Agents. There will be lots of snakes who will eat and dodge each other.
A 3D RayPerceptionSensor detects everything, but there is a specific case where a problem ...
0
votes
1
answer
67
views
BSP Tree Troubles and Unpredictable Results
I've been trying to fix this problem myself for ages, but I really do need help. I'm creating a BSP tree for my 3D game (baked in the map files, quake style) to replace my existing naïve collision &...
0
votes
0
answers
63
views
Why doesn't my Raycast detect AABB collision?
I have the following struct that calculates Raycasting:
...
0
votes
1
answer
160
views
Mouse Ray Picking: Z-Coordinate of Projected vector (glm::unproject)
I've run into a curious issue when implementing ray picking in my game engine.
It seems the Z coordinate of the Projected matrix has to be ever so slightly more than ...
0
votes
1
answer
63
views
Finding the index in a material where a raycast hit
I have a gameobject with a mesh collider. The mesh is simply a flat plane.
I raycast to the mesh and I'd like to get the index on the material's basemap where I got a hit.
I assumed ...
0
votes
0
answers
78
views
How to align to 2D ground surface directly underneath?
I'm out of ideas at this point.
I'm trying to set up a function inside my player controller that aligns the player with whatever is under it (usually the ground), ive tried using Raycasts, collisions ...
0
votes
0
answers
35
views
Ray-Sphere Intersection Always States Ray Origin Is Point Nearest Sphere Center
I am writing a simple graphics engine using Rusts WGPU. I have a Sphere rendering at the origin of my scene like so:
...
0
votes
0
answers
67
views
Red raycast despite valid target in Unity VR
I have a question regarding Unity VR and Interaction Toolkit.
When I point at a UI canvas element, the raycast turns from red to white (indicating that it is a valid target). However, when I create a ...
1
vote
1
answer
58
views
How to detect colored pixel of Sprite3D texture with perspective camera ray?
I've tried to ray cast my mouse position to Sprite3D on screen but I have some problems with it.
...
0
votes
2
answers
112
views
Detecting collisions with trajectories
What if an object were to have collision detection implemented as so: A ray in the direction the object is moving in, and a ray in the direction of gravity.
0
votes
0
answers
24
views
How to stretch a cylinder when dragging with a Ray Interactor?
I'm making a VR game in Unity.
I want to select a cylinder with ray interactor and drag it, and as I drag, it should stretch.
This is the code I have currently for 2D:
...
1
vote
0
answers
48
views
Offset in a raycasting algorithm
I'm trying to implement a function that takes a ray as its start and end position and returns all intersections with the map grid.
I wrote following code and got a problem. Function returns correct ...
1
vote
0
answers
139
views
Problems with RayCasting after fixing fisheye distortion
I am writing a pseudo-3D game in Python. After I tried to fix the fisheye problem, a new one appeared - if you stand close to the wall and look so that the wall is on the side, then the borders of the ...
1
vote
1
answer
274
views
Raycast from isometric view without camera position?
I'm trying to cast a ray so I can implement mouse picking. My game uses 2:1 isometric with a 3D world sim that uses AABBs. Positive X points to the bottom right, positive Y points to the bottom left, ...
0
votes
1
answer
35
views
Can I insert sound in the tooltip?
Before this, I try to insert an image in a tooltip and it was already done. But right now, I want to try to insert a sound in the tooltip. What I want to do is when I point my cursor to the object it ...
0
votes
2
answers
80
views
Display image by using tooltip
I want to display the image using a tooltip. So when I point to the 3dobject, it will display the image that I already created. Right now I already set the sprite in the tooltip but I have an error in ...
0
votes
0
answers
1k
views
How does the UE5 Control Rig Sphere Trace by Trace Channel Work?
I would like to use a control rig to correct the foot IK.
First, I defined a function called "FootTrace" to detect the ground under the feet. In this function, I used "GetTransform-Bone&...
0
votes
1
answer
192
views
How to make raycast go through platform effector?
I'm making a 2D game and I'm using a raycast.
I want the raycast to ignore the platform when hitting it from beneath, but not when hitting it from above.
Right now the raycast always hits no matter ...
0
votes
1
answer
338
views
Fisheye effect on 3D projection
I'm rendering a maze with raycasting in Scratch.
When I'm far away, the walls look nice, but when I'm near the walls they get a weird fisheye effect:
Here is the code for the raycasting:
And the ...
0
votes
1
answer
602
views
Why does my XR ray refuses to cast on my UI?
I have about ten UIs with buttons in my scene. I can cast my XR Ray on all of these UIs and the buttons work fine except two. The buttons on these two UIs are clickable but the rays are not showing on ...
0
votes
0
answers
100
views
Enemy sprite with a raycast ground check is flipping even when it shouldn't
I have a 2D Sprite that patrols around a platform and is supposed to flip when it reaches the edge.
The way the flipping is implemented is through Raycasts. There are two Transforms, on the Left and ...
0
votes
1
answer
238
views
Buttons' hitboxes shift a bit lower when I maximize my game window
I have a simple scene in my Unity 3d project. There is a Canvas (UI Scale Mode in Canvas Scaler is set to Constant Pixel Size but the same is with Scale with screen size), Panel inside it (Stretched ...
0
votes
1
answer
101
views
Platformer enemy with raycast to detect obstacles keeps changing direction rapidly
I am making a 2D platform and implementing a character similar to a Mario Goomba. This character will move left or right, depending on whether or not a raycast determines that there is an object in ...
0
votes
1
answer
925
views
How do I add a pointer to my XR Interactor line visual?
I am setting up my project with XR Interaction toolkit. As usual, there are two red rays from the controllers after the set up as shown below.
However, I want the rays to appear exactly as it is in ...
0
votes
1
answer
357
views
Why is Physics.CapsuleCast returning a mix of true and false when it should return only true?
I'm making a simple character controller. Each frame the player moves by moveDistance units in the moveDir direction.
I'm ...
1
vote
3
answers
1k
views
Explain how Inigo Quilez calculates SDF box normals
Inigo Quilez's website has a page of 3D ray-surface intersectors, one of which is for a basic 3D box:
...
0
votes
1
answer
579
views
Lots of objects with OnMouseDown VS Raycasting: Is one better than the other?
I have a grid of gameobjects with colliders. Currently they all have unity's inbuilt void OnMouseDown function which gets called when the mouse clicks on a collider. This then executes some game logic ...
2
votes
1
answer
251
views
Dealing with block corners in a grid-based raycaster
I'm trying to build a simple grid-based raycaster, but I'm having trouble with rendering block corners.
First of all, I want to change the color of all the y-axis walls. But a block's corner belongs ...
1
vote
0
answers
324
views
Raycasting floor/ceiling textures sliding
I'm writing a raycasting engine in C++ and SFML.
I have the wall texturing done and I'm trying to get floor and ceiling texturing right.
I almost got it but the textures are "sliding" when ...
0
votes
1
answer
234
views
Enemy AI line of sight through Raycast won't behave as expected
I have an issue with my character controller. I'm using a raycast from the enemy AI as a line of sight in order to start following the player. My issue is that with my current character controller ...
0
votes
1
answer
62
views
Score counter not increasing after recalling object from a pool with raycast detection hit
Context
Hello, its me again. I have been playing around with "Object Pool" and it is fascinating the amount of CPU performance can save up. However, I have encountered a new "feature&...
0
votes
1
answer
354
views
Detecting Player by Raycasting
I am having a problem where my ray is unable to detect the player, even if I did layermask and went to draw ray and all other stuff.
Here is my code
...
0
votes
0
answers
52
views
Wheel position on surface
I have a bicycle with suspension and need to find the contact point of the wheel on the "road". If the front fork was pointing straight down, it would be as easy as doing a raycast down the ...
0
votes
1
answer
2k
views
Does Raycast called from Update execute on next FixedUpdate?
I've been searching through the Unity docs (https://docs.unity3d.com/ScriptReference/Physics.Raycast.html), but no matter where I look, I couldn't find exact behaviour of Physics.Raycast() method.
I'...
0
votes
2
answers
87
views
Determine which cannons on a ship can hit a target [closed]
I have a ship that will shoot targets, but cannons on the right side should never try to shot at targets on the left side of the ship. Thus I have created sectors using the ...
1
vote
1
answer
404
views
Raycasting : computing x position of sprite on the screen
I am trying to create a raycasting engine using C and CSFML, I already have the walls and textures rendering done and right now I would like to be able to render sprites into the scene.
The difficulty ...
0
votes
0
answers
706
views
Using a Raycast to stop the player from going through walls
I've been having this problem in the last couple of hours and I was just thinking if someone could help me figure it out, since I am unfortunately not a programmer, or at least a good one at all.
I'm ...
1
vote
2
answers
1k
views
Line-of-sight algorithm for tile-based tactics
I've tried Bresenham line and Raycasting, but they don't quite give the results I need (examples in the screenshot).
'&' - character
'+' - cells that can be attacked by the
character
'#' - walls
...
0
votes
0
answers
317
views
How to shoot raycast, and display image on canvas
I have been trying to work on raycast, where if a raycast hits an object then an image will be displayed on the canvas, like on COD Warzone if I go to an elevator shaft, and look at the wire to go up, ...
1
vote
0
answers
487
views
Raycasting to determine point inside or outside mesh, edge case?
I'm trying to determine if a point is inside or outside a (triangle) mesh.
The best way I found was to cast a ray from the point and count how many triangles intersect. (Odd or even).
I used Möller–...
1
vote
0
answers
66
views
Floorcasting not scrolling in raycaster?
I'm currently working on a raycaster in Java, and so far, I have the floor correctly textured. The problem, however, is that the floor doesn't scroll. In other words, when I move the camera in the ...
0
votes
1
answer
5k
views
How to detect if hit by raycast from object with name/tag
INTRODUCTION:
In unity, I want to make a dynamic, object use system. Where the main player camera shoots a raycast when left mouse button is clicked and if an object that can be used for example a ...
0
votes
0
answers
68
views
Help with particles and raycasting
I have a 3D side scroller style game in which the player flies along avoiding stuff, you know, side-scrollery things.
I'd like to add an effect (particle system) to the player when they get close (say ...
1
vote
1
answer
113
views
Reflection Line2D
I found a video on YouTube with a sercol and a beam, and everything seems to be fine, but the beam doubles and flickers after spawning from the mirror, tell me what could be the problem, screenshot ...
1
vote
1
answer
867
views
Trying to get sprite from isometric "z as y" tilemap
I'm using code like the following with a tilemap and tilemap collider 2d:
var ray = Physics2D.RaycastAll(worldCoordinate, Vector2.zero);
Unfortunately, when I ...
1
vote
1
answer
114
views
Determine if a static mesh is lit by directional light
I want to determine if a mesh is lit by the directional light on my scene in editor to automatically disable its "dynamic shadow casting" property (let's say I have one light source in my ...
0
votes
1
answer
1k
views
Can't add script behaviour Interactable. The script class can't be abstract!
I'm building a Raycast setup where game objects run code on click / touch.
...