Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
0answers
16 views

Unity5 Boxcast/ Raycast Rotate with Parent

I started with the API Scripting reference's Physics.BoxCast example code: [https://docs.unity3d.com/ScriptReference/Physics.BoxCast.html] ...and it works great... until the game object rotates, see: ...
0
votes
0answers
20 views

Explanation Morgan's McGuire Screen Space Ray Tracing method

I tried to implement the Morgan's McGuire method, but my attempts failed. He described his method here: Screen Space Ray Tracing. Below is my code and screenshot. SSLR fragment shader: ...
0
votes
0answers
9 views

Making a fully functional SteamVR UI Pointer in Unity?

I tried this tutorial and now can click buttons with a pointer, but that example ends short of anything truly useful as you cannot interact with scroll rects or anything beyond clicking. What I need ...
0
votes
1answer
46 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
31 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 ...
0
votes
0answers
20 views

How to do 2D top-down raycasted shadows to hide the map not visible by the player, but adding an extra parameter; terrain height?

The effect I'm going for is found on this neat website: http://www.heywhatsthat.com/ In effect, it's a map that will highlight everything visible to someone standing at the pip. So, if there's a ...
1
vote
1answer
29 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: ...
0
votes
0answers
24 views

How to prevent object tunneling through ground when under influence of gravity?

I am currently trying to implement 2D continuous collision detection to predict the time to collision between two objects and subsequently apply a collision response. I achieve this by casting a ...
1
vote
1answer
56 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
0answers
51 views

OpenGL Ray Transformations

Sorry for my english at first. I have method for ray intersection test and it works. If I apply a transformation to an object, the method does not see it. I think that happens because I'm using wrong ...
0
votes
0answers
14 views

RaycastHit2D collision detection problem?

I want to add a ray to the mouse position and detect the objects with this ray. I made it but there is a problem: ray doesnt collide with objects sometimes. the code: ...
0
votes
2answers
29 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
99 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
13 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
8 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
41 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
88 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
0answers
13 views

Unity (2D): Masking part of objects out of field of view

I'm working on a 2D Unity project where people can only see objects in their field of view. I have successfully created a quad overlay that masks out any ground outside of your field of view. What is ...
0
votes
1answer
21 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
40 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
25 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
82 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 ...
0
votes
0answers
59 views

How can I raycast a floor in a simple raycasting engine?

I've been following the infamous lodev raycasting tutorial for a little while now but I can't make heads or tails of how the raycasting for the floor/ceiling works. He seems to be drawing the floor ...
0
votes
0answers
47 views

Raycasting — invalid floorcasting texture mapping

The problem is that the floor moves with the player in same time. In the correct implementation, the player must walk on the floor. I attach the animation on which this effect is visible (in spoiler), ...
0
votes
1answer
124 views

Why RaycastAll misses some objects?

Update 2 (see below) I'm writing a turn-based game. During setup phase time scale modifier equals to 0, what prevents running of any physics-based code and FixedUpdates. User have freezed action and ...
2
votes
0answers
182 views

ray-casting, floor-casting part fails

I'm currently working on a ray-casting engine in Java and I can't figure out what's wrong with my code. For the learning and theory I use: The permadi tutorial: ( https://permadi.com/1996/05/ray-...
1
vote
1answer
100 views

efficient 2D light source

I wanted to add a light source for a project I'm working on, and luckily I had some code based on this article: http://ncase.me/sight-and-light/, but when I ran the code after carefully transplanting ...
0
votes
0answers
26 views

Issue in projecting mesh onto the image

I have a triangle mesh which I read from ply file and build AABB tree using it. ...
1
vote
0answers
25 views

Best aproach to Ground level detection for spells/skills

I'm making a 3d Hero Defense/Tower defense kind of game with unity3d. A made a skill system with scriptable objects that lets the Defender use skills on the terrain doing damage to enemies that can be ...
0
votes
1answer
149 views

Difference between 'max distance' and 'radius' in Physics.SphereCastAll

I needed a way to check for all gameobjects within a set sphere of my player object. I found Physics.SphereCastAll which will return a RaycastHit[], exactly what I wanted. But, I am having trouble ...
0
votes
1answer
106 views

Debug.DrawLine doesn't go straight

Heres the code: ...
0
votes
1answer
40 views

RayCast seems to ignore some objects?

I'm currently using a Raycast both for my movement check aswell as a focus-setting check, both checks use pretty much the same code. The problem i'm having is that the Raycast goes through some ...
0
votes
0answers
22 views

[Unity]: Make one button highlight color activated when pointing at another button in same location

I have two buttons. One is a play button. Another is used as a tint for a background so when I am pointing at play button, the background should change its tint. Problem is when I point at play ...
0
votes
0answers
18 views

Raycasting issues

I have this raycasting code: ...
0
votes
0answers
49 views

Unity C# How to calculate end position between two vector3's using max distance

I know the title is a bit confusing. Reason why I haven't been able to do this myself is because I am a bit confused on how to go about doing this. This is what I want: When the player uses a skill,...
0
votes
1answer
40 views

Enemy fire does not travel to player using RayCast2D

Enemies are using raycast to fire and detect player. The bullet has its own script that makes it move forward after instantiating it, but the problem is that it always moves in the right direction and ...
0
votes
2answers
181 views

How can I correct an unwanted fisheye effect when drawing a scene with raycasting?

Hello I have a game using raycasting for the TI Nspire in Lua, and when the player faces a wall so that their degree they are facing is perpendicular to the length of the wall, I am having what is ...
0
votes
1answer
179 views

Using raycast to detect whether a wall immediately blocks a player in Unity C#

I am working on a game project of which involves a procedurally generated maze. Within this maze, there are different types of tiles, such as walls and gates. I want to program the player so that it ...
1
vote
2answers
121 views

In Unity, is there a difference between Vector3.down and -Vector3.up?

I've noticed numerous tutorials and examples using something like "transform.up * -1" or "-Vector3.up" instead of simply saying "transform.down" and "Vector3.down". Is there a good reason for this, ...
0
votes
2answers
177 views

Raycast in Unity for ground detection returns false while touching ground

I'm using a raycast to detect the player's distance to the ground for a hovercraft game. The raycast works correctly (returns true and also returns the distance to the first impact) until the moment ...
1
vote
1answer
72 views

Unity 2017.3.of3 Raycast2D randomly misses objects

2d up down platformer. Character has 2 Rays(one left one right) going down, when either Ray's hit distance hits between -1 and 1 it should call a function which will change character direction from ...
4
votes
0answers
79 views

Determine user mouse selection of 3D Object for multiple viewports

I am currently working on setting up some world objects for my level editor and am running into a bit of a snag. When I get the hit location from the mouse raycast, I would like to determine what part ...
2
votes
1answer
81 views

Drawing Explosions Respecting Walls

I am creating a tiled game (2D top down) and I created explosions working this way: The blue lines are walls, the white grid is accessable space. The red dot is the origin of the explosion with the ...
2
votes
1answer
73 views

How can I ungrab the grabbed Object in Unity?

I modified a grab Script to my purpose, I can grab the Object and make it a parent to the character with the Key "G" but I want to let it go and detach the parent of the picked Object with "H" with ...
0
votes
0answers
59 views

Cast a Ray In C++ Directx9.0c

I'm in the process of attempting to mod Quake 4, and one of the features I am attempting to implement is teleportation. With that said, I want to know how to perform the casting of a ray. I wish to ...
1
vote
1answer
55 views

How to prevent cube intersecting with other objects when moved around with mouse?

I want to allow the player to freely place cubes anywhere they like in 3D space, but the cube being moved around is not allowed to intersect with other objects. Currently I do a ray cast based on ...
0
votes
1answer
104 views

How to “reset” velocity.y when entering water?

I'm using a raycast controller and kinematic ridigbody. The way I've got my project set up is that I have a set of default values, such as gravity, jump height, etc., and when I enter a certain ...
2
votes
0answers
358 views

Unity2D: Proper way to implement ladder climbing with a raycast controller?

I originally posted this on Stack Overflow, but was told I might have more luck here: I've been slowing grinding out programming features for my character controller, and one of the last things to ...
0
votes
1answer
222 views

Unity: RaycastHit2D continually returns point (0,0)

firstly I'm a bit of a Unity noob so sincere apologies if I've done something dumb. I'm attempting to use a RaycastHit2D to detect when the player is on a platform. If he is, the point it returns ...
1
vote
1answer
162 views

Pressing two buttons on Android with same thumb touch. UI Event Triggers not working. Workaround found

NOTE: See bottom of the question as I have managed to use a workaround which works to press the two buttons at once on Android (thanks to Douglas Potestas help) Ive struggled with this in the past ...