Data Realms Fan Forums
http://forums.datarealms.com/

Rays and distances: a hover drone
http://forums.datarealms.com/viewtopic.php?f=73&t=45853
Page 1 of 1

Author:  4zK [ Fri Nov 14, 2014 5:27 pm ]
Post subject:  Rays and distances: a hover drone

Hover drone idea:

  • 360 terrain (ray) detection
  • The drone keeps a distance to all surfaces around it
    → Finds a center position in tunnels
  • Said distance increases in movement
    → Allows more precise slow movement closer to the terrain(?)

What I need:

  • 360 terrain (ray) detection
  • The distance value from closest terrain
    → velocity/position change relative to said distance

How do I said things?

Also, upon approach of a wall, the horizontal movement could be turned into upward vertical movement for smooth obstacle scaling

Thanks in advance for possible help

Author:  Asklar [ Fri Nov 14, 2014 6:31 pm ]
Post subject:  Re: Rays and distances: a hover drone

One of the biggest problem would be the ray part. Casting so many rays would probably end up being laggy. In case it's not, just a simple loop that rotates the vector of the ray would be enough, then you could store all the distances in a list and do your desired operations, like checking if all the distances are longer than what you need, and in case it's not, move further from it. A problem I imagine would be travelling through a tunnel that gets narrower or wider, in that case, the distance you want from the terrain would have to depend on something, for example the velocity as you stated, or probably something like the biggest and shortest distance you are currently measuring.

Hovering in "the middle" of a tunnel, for example, could be somewhat weird given terrain in CC though. Say, for example, you have a cave or tunnel that has some holes or the ceiling part is damaged. Probably when moving inside of it, in one part the floor/ceiling distance will be X, later it'll be X+Y, etc., the drone would end up oscilating as it moves. Inside an undamaged bunker it'd work perfectly.

I think it's perfectly possible to do, though a clean implementation wouldn't be very simple.

PS: I might be overcomplicating things up, though there's multiple solutions for most problems.

Author:  CaveCricket48 [ Fri Nov 14, 2014 7:18 pm ]
Post subject:  Re: Rays and distances: a hover drone

Something something Fermat's spiral variant of the raycast.

Starts in the origin, spirals outward, so the first point you hit would be the closest.

Trying to dig up the PMs I sent to Arcalane about it, made functional scripts too that he's using in his WH40K mod I think.

Author:  4zK [ Fri Nov 14, 2014 7:23 pm ]
Post subject:  Re: Rays and distances: a hover drone

I thought the rays would be laggy yeah. Anyhoo a less laggy substitute is totally fine.

The middle hovering part would come from avoiding terrain around all sides. This should ensure that the drone doesn't even have a chance to get into a distorted enough area that it couldn't handle. A standard bunker tunnel would be a fair limit.

Also maybe the hovering distance would affect speed vice versa? As in you couldn't speed up as fast in tighter areas than in open ones, like the surface.

EDIT: thx CC

Author:  Arcalane [ Fri Nov 14, 2014 7:24 pm ]
Post subject:  Re: Rays and distances: a hover drone

CaveCricket48 wrote:
Something something Fermat's spiral variant of the raycast.

Starts in the origin, spirals outward, so the first point you hit would be the closest.

Trying to dig up the PMs I sent to Arcalane about it, made functional scripts too that he's using in his WH40K mod I think.


Just forum-search for 'fermat', there's literally four results on the entire forum (well, five now).

Anyways, take a look at my post and Cave's after for a look at the fermat's spiral stuff.

Author:  Bad Boy [ Fri Nov 14, 2014 7:38 pm ]
Post subject:  Re: Rays and distances: a hover drone

If you don't want to do the work this has something that may be pretty similar to what you want.

Author:  4zK [ Fri Nov 14, 2014 10:15 pm ]
Post subject:  Re: Rays and distances: a hover drone

So I guess I can make this detect terrain on my own...

Now that I know the nearest point though, how do I add velocity parallel to the point and the drone?

Author:  CaveCricket48 [ Fri Nov 14, 2014 10:26 pm ]
Post subject:  Re: Rays and distances: a hover drone

Assuming "point" is your detected terrain position:

Code:
   local dist = SceneMan:ShortestDistance(self.Pos,point,SceneMan.SceneWrapsX);
   if dist.Magnitude < 10 then
      self.Vel = self.Vel + Vector(5,0):RadRotate(dist.AbsRadAngle);
   elseif dist.Magnitude > 12 then
      self.Vel = self.Vel + Vector(-5,0):RadRotate(dist.AbsRadAngle);
   end



Something like that.

Author:  4zK [ Fri Nov 14, 2014 10:52 pm ]
Post subject:  Re: Rays and distances: a hover drone

Works more or less just as I imagined it, thanks.

Now to fiddle with velocity relativity and other stuff, I think I got this now.

EDIT: Man. This turned out really smooth. By the looks of it though, it's sad that the crab AI isn't exactly fit for using jetpacks...

Maneuvering obstacles would have been simple with jetpack use. Is there some way that I can implement that in the crab AI?

EDIT2: Btw: what I did was make the "repulsion" velocity the inverse value of dist.Magnitude, it gives it a very magnetic-like repulsion effect towards terrain, looks really smooth.

Has a pretty hard time going through smaller holes... but nothing that it would need that much.

Author:  clunatic [ Tue Nov 25, 2014 7:13 pm ]
Post subject:  Re: Rays and distances: a hover drone

Is there any particular reason it needs to be a crab? You could go for a AHuman with a null.bmp head and fg arm + a little lua magic. That would at least allow you to use the human AI.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/