| 
 
 
 
	
	
		
			|   | Page 1 of 1 
 | [ 4 posts ] |  |   Shooting ObstacleRay straight up 
        
        
            | Author | Message |  
			| Djinn 
					Joined: Sun Oct 29, 2006 4:26 am
 Posts: 298
   |   Shooting ObstacleRay straight upMan this should be super easy but I cannot find an answer to this - I want something to activate upon detecting a ceiling 5 or so pixels above it. So what I'm looking for is the code to first cast the ray, and second to actually place in the if statement. Any help is appreciated. 
 
 |  
			| Wed Oct 03, 2012 8:41 pm | 
					
					     |  
		|  |  
			| Sallen 
					Joined: Tue Feb 09, 2010 4:16 pm
 Posts: 86
   |   Re: Shooting ObstacleRay straight upFrom here: http://wiki.datarealms.com/SceneMan:CastObstacleRay What you need to do is something like: Code: self.startPos = Vector(120, 422); -- This is from where you start casting the ray. It could be self.Pos for an Actor, etc.self.collisionPos = Vector(0,0);
 self.preCollisionPos = Vector(0,0);
 SceneMan:CastObstacleRay(self.startPos, Vector(0, -5), self.collisionPos, self.preCollisionPos, 0, -1, 0, 1);
 
After that, if self.collisionPos is different from Vector(0,0), that means the ray encountered an obstacle (and self.collisionPos contains the coordinates of the obstacle). So: Code: if self.collisionPos ~= Vector(0, 0) then-- do stuff
 end
 
I haven't tested any of this, so I may have something wrong. The basic idea still holds though. If you have more questions please try to be specific.
 
 |  
			| Wed Oct 03, 2012 9:40 pm | 
					
					   |  
		|  |  
			| Djinn 
					Joined: Sun Oct 29, 2006 4:26 am
 Posts: 298
   |   Re: Shooting ObstacleRay straight upSallen wrote: From here: http://wiki.datarealms.com/SceneMan:CastObstacleRay What you need to do is something like: Code: self.startPos = Vector(120, 422); -- This is from where you start casting the ray. It could be self.Pos for an Actor, etc.self.collisionPos = Vector(0,0);
 self.preCollisionPos = Vector(0,0);
 SceneMan:CastObstacleRay(self.startPos, Vector(0, -5), self.collisionPos, self.preCollisionPos, 0, -1, 0, 1);
 
After that, if self.collisionPos is different from Vector(0,0), that means the ray encountered an obstacle (and self.collisionPos contains the coordinates of the obstacle). So: Code: if self.collisionPos ~= Vector(0, 0) then-- do stuff
 end
 
I haven't tested any of this, so I may have something wrong. The basic idea still holds though. If you have more questions please try to be specific.Hi, thanks for your help. I put the code in and it seems to work - at least, no errors, and the effect properly happens when it's against a ceiling. However, it ALSO happens when it's not touching the ceiling. Code: function Create(self)self.LifeTimer = Timer();
 end
 
 function Update(self)
 self.ToSettle = false;
 
 self.startPos = self.Pos; -- This is from where you start casting the ray. It could be self.Pos for an Actor, etc.
 self.collisionPos = Vector(0,0);
 self.preCollisionPos = Vector(0,0);
 SceneMan:CastObstacleRay(self.startPos, Vector(0, -5), self.collisionPos, self.preCollisionPos, 0, -1, 0, 1);
 
 if self.LifeTimer:IsPastSimMS(4000) and self.collisionPos ~= Vector(0,0) then
 self.ToDelete = true;
 local createmissile = CreateMOSRotating("Orange Bush","Xenobiology.rte")
 createmissile.Pos = self.Pos;
 MovableMan:AddParticle(createmissile);
 end
 
 end
Code is as follows, and I frankly don't know enough about ObstacleRays to correct the issue. Any ideas?
 
 |  
			| Wed Oct 03, 2012 11:58 pm | 
					
					     |  
		|  |  
			| Technomancer 
					Joined: Sat Jul 31, 2010 10:01 pm
 Posts: 42
   |   Re: Shooting ObstacleRay straight upCode:    local obsray = SceneMan:CastObstacleRay(self.Pos,Vector(0,-7),Vector(),Vector(),self.ID,self.Team,0,0);if self.LifeTimer:IsPastSimMS(4000) and obsray <= 5 and obsray > 0 then
 self.ToDelete = true;
 local createmissile = CreateMOSRotating("Orange Bush","Xenobiology.rte")
 createmissile.Pos = self.Pos;
 MovableMan:AddParticle(createmissile);
 end
Should work. For this case you probably don't need the collision pos or the pre-collision pos vectors. Will also ignore itself and MOs on its team when casting, change the self.ID and self.Team back if you don't want that.
 
 |  
			| Thu Oct 04, 2012 6:04 am | 
					
					   |  
		|  |  
		|  |  
	
		
			|   | Page 1 of 1 
 | [ 4 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
 
 |  
 |