Guest User

Untitled

a guest
Jan 3rd, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1.  
  2. function Create(self)
  3. --collision stuff
  4. self.victim = nil;
  5. self.rootVictim = nil;
  6. self.hasnthityet = true
  7. --parent finding wooo
  8. self.parent = MovableMan:GetMOFromID(MovableMan:GetRootMOID(SceneMan:CastMORay(self.Pos,(self.Vel * -50),255,-1,0,true,3)));
  9. if self.parent == nil then
  10. self.box = Box(self.Pos - Vector(30,30),self.Pos + Vector(30,30))
  11. --just in case raycasting doesnt work properly.
  12. for actor in MovableMan.Actors do
  13. if self.box:GetWithinBox(actor.Pos) then
  14. self.parent = MovableMan:GetMOFromID(actor.RootID)
  15. self:SetWhichMOToNotHit(self.parent, 2)
  16. end
  17. end
  18. end
  19. self.Massmultiplier = self.Mass * 5
  20. end
  21.  
  22. function Update(self)
  23. if self.victim == nil then
  24. self.targetID = SceneMan:CastMORay(self.Pos,((self.Vel / self.Vel.Magnitude)*20),self.parent.ID,-1,0,0,false,5);
  25. if self.parent.RootID ~= MovableMan:GetRootMOID(self.targetID) and self.targetID ~= nil then
  26. if self.targetID ~= 255 and MovableMan:GetRootMOID(self.targetID) ~= self.parent.ID then
  27. self.dist = (MovableMan:GetMOFromID(MovableMan:GetRootMOID(self.targetID)).Pos - self.Pos).Magnitude;
  28. if self.dist < 40 then
  29. self.victim = MovableMan:GetMOFromID(MovableMan:GetRootMOID(self.targetID));
  30. self.victim.Vel = Vector(((self.Vel.X * (2 / self.victim.Mass)) + self.victim.Vel.X) , ((self.Vel.Y * (2 / self.victim.Mass)) + self.victim.Vel.Y))
  31. self.victim:AddImpulseForce(((self.Vel / 2) + (self.Vel * self.Massmultiplier)) / 2, (self.victim.Pos - self.Pos))
  32. end
  33. end
  34. end
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment