View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:45 am



Reply to topic  [ 10 posts ] 
 Terrain proximity MOPixel deletion 
Author Message
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Terrain proximity MOPixel deletion
This code deletes an MOPixel when close/close enough to terrain.
Code:
function Update(self)
   if self:GetAltitude(5,2) < 3 then
      self.ToDelete = true;
   end
end

However.
This seems to be completely ineffective when you shoot straight up.
I shoot horizontally, my bullets do little/nothing to the terrain.
I shoot vertically, my bullets disregard the presence of terrain and eat it right up.

What would the script for vertical shots be?


Thu Nov 12, 2009 1:53 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Terrain proximity MOPixel deletion
you'd have to use caststrengthrays, cause obstaclerays will hit MOs and make the bullet useless. look at the sceneman docs for reference


Thu Nov 12, 2009 2:32 am
Profile WWW
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Terrain proximity MOPixel deletion
Lemme explain this a bit more clearly:
I'm making a gun that shoots a massive amount of bullets along a single line. The bullets are meant to kill virtually anything, which is a downside because of terrainrape. Then I remembered I saw the terrain code and applied that to the bullets. However, it only works the closer I am to aiming horizontally. The farther away from aiming along the horizontal axis, the more terrain it goes through.


Thu Nov 12, 2009 2:38 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Terrain proximity MOPixel deletion
i know what it does. if you use strengthrays to check for terrain rather than altitude (which checks directly below the particle) you're more likely to have success.


Thu Nov 12, 2009 2:40 am
Profile WWW
User avatar

Joined: Sat Jun 16, 2007 2:31 am
Posts: 2982
Location: Texas
Reply with quote
Post Re: Terrain proximity MOPixel deletion
...Right.
So how do I do that?


Thu Nov 12, 2009 4:42 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Terrain proximity MOPixel deletion
The other problem with this is that altitude is determined by basically moving the particle's position to the ground below it. If you're shooting upward, there's never ground below it until it's inside of the terrain, because the terrain is above it. If you're shooting downward, chances are that the bullet is moving too fast for it to detect the altitude before it's already in the terrain.
tl;dr just use a strength raycast.


Thu Nov 12, 2009 4:44 am
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Terrain proximity MOPixel deletion
Or have a StrengthRay that points in the direction of the MOPixel's direction, which is what I use in my Flechette gun.

Code:
local terrcheck = Vector(0,0);
if SceneMan:CastStrengthRay(self.Pos,Vector(self.Vel.X,self.Vel.Y):SetMagnitude(10),0,terrcheck,0,0,true) then


Change the "SetMagnitude" to the length of the ray (in pixels). "terrcheck" is where the terrain pixel was struck, so you don't need to touch that.


Thu Nov 12, 2009 4:54 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Terrain proximity MOPixel deletion
its funny how we all said the same thing.


Thu Nov 12, 2009 6:06 am
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Terrain proximity MOPixel deletion
Oops. Well, at least if whitty doesn't understand one of our posts, he has 2 other to look at.


Thu Nov 12, 2009 12:24 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Terrain proximity MOPixel deletion
indeed. and if anyone else asks this question ever again, they'll get slaughtered.


Thu Nov 12, 2009 1:53 pm
Profile WWW
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.051s | 13 Queries | GZIP : Off ]