Comments (16)
protected override void OnUpdate()
{
Vector3 start = Transform.Position;
Vector3 end = start + Vector3.Down * 12;
var traceResult = Scene.Trace.Sphere( 32, start, end ).Run();
/* Draw end position of sphere */
Gizmo.Draw.IgnoreDepth = true;
Gizmo.Draw.Color = Color.Red;
Gizmo.Draw.LineSphere( traceResult.EndPosition, 32 );
/* If there's a hit, draw the hit position */
if ( traceResult.Hit )
{
Gizmo.Draw.Color = Color.Green;
Gizmo.Draw.SolidSphere( traceResult.HitPosition, 2.0f );
}
}
2024-09-11.19-36-05.mp4
from sbox-issues.
This should be fixed now.
sbox-dev_CvSjg1QMpX.mp4
from sbox-issues.
Nice! That looks great. I tried the latest build just now but it was still wrong, Iβm assuming itβs still pending?
Also, I noticed the hit normal returned was wrong sometimes, but I will make a new issue if I can confirm it with your new fixes. Much appreciated!
from sbox-issues.
Can you show it not working? Repro?
from sbox-issues.
Ok so I did some tests. It seems to work fine with scene objects, but not with map instaces. So the repro would be to try and load any map. In my test I used flat grass. In the video below you can see how as soon as it moves away from the gray box ( which is a scene object that I added ) and hits the map instance it shows the wrong hit position:
sbox.2024.01.25.18.21.41.mp4
Hope that's helpful!
from sbox-issues.
Should be fixed now
from sbox-issues.
It works! But still has some other issues, I'll post them below:
- When you do a sphere trace but start and end position of the trace is the same location, the normals returned don't make sense. In the video below I start with a trace of like 40 units, then 20 units, then 0, as you can see the normal returned for 0 is odd.
uynghv.mp4
- Odd normal behavior when moving trace around on a flat wall ( double checked, fully flat ). In the video below I have made the trace not 0.0 to avoid the issue above, it's set at like 2.0. The trace works fine on the floor and even on the wall, but as you move the trace around ( on a flat wall ) you get differing normals returned.
l6jd4h.mp4
Thanks!
from sbox-issues.
So I did more tests in my actual use-case ( I want to sphere test a slightly larger radius sphere than the pawn sphere, so I can use it for fancy wall-jumps etc. This is all ported from UE4 ). While doing so I noticed some very inconsistent normals even when on the floor. When viewed with the physics debug it perhaps gives a better idea of what's going on. Video below:
9l2m5n.mp4
from sbox-issues.
I wouldn't expect a trace with no delta to work, any detection is going to start in solid.
from sbox-issues.
All of these issues look like because you're trying to start a trace inside a solid
from sbox-issues.
The traces do start in solids, perhaps for reference footage from how Unreal handles it ( porting an old project to learn S&Box, so if there's a better way of doing things, I'm all ears!)
As you can see, I do a much larger sphere test to detect walls/floors/edges. Unreal ( PhysX in this case ) returns the following succesfully:
- Location: a point in space where you can put the swept shape where it would not be penetrating
- Impact Point: the position on the surface that was hit
- Impact Normal: the actual surface normal of the object that was hit
- Normal: for a sphere this is a normal pointing to the center of the sphere ( for a line its the same as impact normal )
normals_in_unreal.mp4
I am looking for the equivelant of the normal that I'm getting in this video, I use it for all kinds of edge-jump boost type of stuff. The ball itself does not always have collision ( does for most of the time ) so I can't rely on actual collision information unfortunately.
Hope that's useful!
from sbox-issues.
If unreal handles sphere traces starting in solid then we should too. I just don't know what the timeframe on that will be, it's not an easy thing to get right.
from sbox-issues.
Totally understand! For this specific project I'll try some hacky methods for now. Thanks for taking a look :)
from sbox-issues.
this bug has appeared again :<
from sbox-issues.
Could you provide more information, like sample code, an image, a video?
from sbox-issues.
hit position for sphere casts should work again
from sbox-issues.
Related Issues (20)
- [Editor] Component.OnDestroy is executed in editor without Component.ExecuteInEditor
- Cannot rebind key binds in-game
- TextEntry doesn't auto defocus if other UI elements are clicked on
- Project Settings - Resources Files should be able to exclude directories/files as well as adding them
- Use T param on a component break its style
- Allow users to derive `ScreenPanel` and `GameRootPanel`
- sbox.game screenshot order is inconsistent and confusing
- Ability to use custom attributes that rely on reflection HOT 3
- De-clutter Object and Component creation menu HOT 1
- SSAO render order broken
- Add rotation to Trail/Line renderer HOT 1
- [REGRESSION] GameTask.Delay and DelaySeconds get stuck and never resolve HOT 4
- Vulkan Device Lost when opening project HOT 1
- Accessing Gizmo related things produces errors when not called from DrawGizmos
- Error launch
- [REGRESSION] Playing a scene no longer switches to the game view HOT 1
- [REGRESSION] Game scene view is no longer created HOT 1
- Value cannot be null error
- [ModelDoc] Hook up "IK lock" to regulard IK chains
- Bring back "comparable" sound slider
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbox-issues.