Data Realms Fan Forums http://45.55.195.193/ |
|
Shooting ObstacleRay straight up http://45.55.195.193/viewtopic.php?f=73&t=31840 |
Page 1 of 1 |
Author: | Djinn [ Wed Oct 03, 2012 8:41 pm ] |
Post subject: | Shooting ObstacleRay straight up |
Man 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. |
Author: | Sallen [ Wed Oct 03, 2012 9:40 pm ] |
Post subject: | Re: Shooting ObstacleRay straight up |
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. |
Author: | Djinn [ Wed Oct 03, 2012 11:58 pm ] |
Post subject: | Re: Shooting ObstacleRay straight up |
Sallen 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? |
Author: | Technomancer [ Thu Oct 04, 2012 6:04 am ] |
Post subject: | Re: Shooting ObstacleRay straight up |
Code: 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |