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
1answer
35 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
12 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
7 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
35 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
35 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
12 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
14 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
39 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
24 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
54 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
47 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
42 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
84 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
154 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
91 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
22 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
24 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
94 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
75 views

Debug.DrawLine doesn't go straight

Heres the code: ...
0
votes
1answer
39 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
16 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
16 views

Raycasting issues

I have this raycasting code: ...
0
votes
0answers
34 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
38 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
161 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
117 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
108 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
117 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 ...
0
votes
1answer
59 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
68 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
72 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
65 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
54 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
49 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
89 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
279 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
177 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
124 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 ...
1
vote
2answers
175 views

Fastest visibility calculation towards all possible directions

I am searching for your advice. I have a massive voxelized model, like the one in the picture (but with a few million voxels more..). To reduce the total number of the model’s triangulations, I can ...
0
votes
0answers
12 views

Do not change to the “fly” state at the end of the platform in unity2d

How can I do not change to the "fly" state at the end of the platform in unity2d? Here is what I would like the character do when he/she is standing at the platform: Here is what he/she is doing ...
0
votes
1answer
124 views

Raycast can't hit my player

I have been trying for the past 5 hours to get this to work. So i have an enemy that has the following script: ...
1
vote
1answer
90 views

undetected colission

I'm doing a simple grid based game, where the player should only be able to move on the grey cells. It works quite ok, but in this simple scenario, the player is able to walk through Wall(1), although ...
0
votes
0answers
132 views

Unity: How to Raycast in a 360 VR video?

I have set up a basic inverted sphere in unity and am running a 360 video inside it and it is working fine in VR. But i want to raycast inside that video to show information about some objects which ...
0
votes
0answers
170 views

Java Raycasting Engine Floor and Ceiling Texture Problems

As of recently, I have been working on a simple raycasting engine. My problem so far has been displaying floor and ceiling textures properly. My current code seemingly only takes one pixel from the ...
0
votes
1answer
193 views

How to get object position from a ray hit?

I've been coding a program to teleport an object to a player hands(which is just and empty game object). I did this using ray collision on mouse down, but I cant think of a way to find the position of ...
0
votes
1answer
87 views

Why does this raycast code give me a NullReferenceException?

The Error in the code is NullReferenceException: Object reference not set to an instance of an object for if (hitxx.collider.tag == "soldier") Please help! Thanks in advance ...
0
votes
1answer
763 views

Raycasting from 3D object to UI canvas!

I have a world space canvas in front of the player and I want to shoot a ray towards an enemy (in the direction of the enemy) and create and object where Raycast hits the UI canvas. I know that the ...
0
votes
1answer
54 views

Ray is not shooting forward

This is the code for Raycast: ...
0
votes
0answers
33 views

Raycast always shoots horizontally

I'm building a character controller and environment from total scratch to give me experience and I got to the point where I'm writing a script to detect objects and output some tooltip to the player. ...