View unanswered posts | View active topics It is currently Wed Dec 25, 2024 5:05 pm



Reply to topic  [ 10 posts ] 
 Rays and distances: a hover drone 
Author Message
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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


Fri Nov 14, 2014 5:27 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post 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.


Fri Nov 14, 2014 6:31 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Fri Nov 14, 2014 7:18 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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


Fri Nov 14, 2014 7:23 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post 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.


Fri Nov 14, 2014 7:24 pm
Profile YIM

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post 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.


Fri Nov 14, 2014 7:38 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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?


Fri Nov 14, 2014 10:15 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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.


Fri Nov 14, 2014 10:26 pm
Profile
User avatar

Joined: Mon Oct 11, 2010 1:15 pm
Posts: 594
Location: Finlandia
Reply with quote
Post 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.


Fri Nov 14, 2014 10:52 pm
Profile

Joined: Fri Nov 23, 2012 5:42 am
Posts: 143
Reply with quote
Post 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.


Tue Nov 25, 2014 7:13 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.043s | 13 Queries | GZIP : Off ]