GithubHelp home page GithubHelp logo

Comments (16)

kekobka avatar kekobka commented on September 15, 2024 1
	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.

aylaylay avatar aylaylay commented on September 15, 2024

This should be fixed now.

sbox-dev_CvSjg1QMpX.mp4

from sbox-issues.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

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.

aylaylay avatar aylaylay commented on September 15, 2024

Can you show it not working? Repro?

from sbox-issues.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

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.

aylaylay avatar aylaylay commented on September 15, 2024

Should be fixed now

from sbox-issues.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

It works! But still has some other issues, I'll post them below:

  1. 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
  1. 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.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

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.

aylaylay avatar aylaylay commented on September 15, 2024

I wouldn't expect a trace with no delta to work, any detection is going to start in solid.

from sbox-issues.

aylaylay avatar aylaylay commented on September 15, 2024

All of these issues look like because you're trying to start a trace inside a solid

from sbox-issues.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

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.

aylaylay avatar aylaylay commented on September 15, 2024

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.

osmanlodzero avatar osmanlodzero commented on September 15, 2024

Totally understand! For this specific project I'll try some hacky methods for now. Thanks for taking a look :)

from sbox-issues.

kekobka avatar kekobka commented on September 15, 2024

this bug has appeared again :<

from sbox-issues.

MD485 avatar MD485 commented on September 15, 2024

Could you provide more information, like sample code, an image, a video?

from sbox-issues.

aylaylay avatar aylaylay commented on September 15, 2024

hit position for sphere casts should work again

from sbox-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.