DanceTweety Posted June 18, 2014 Share Posted June 18, 2014 I am trying to make a trigger box to detect a ball using CollisionTrigger.lua. But it only detects the player. How can I change this the ball is a prop and has a phy file. Any help is welcome I also tried the Selective Collision Trigger 1.0 but it does also not detect the ball I also dont see how I can put a Entity in the box and even it I place it in the script it does not show up in the input box. Quote Link to comment Share on other sites More sharing options...
DanceTweety Posted June 23, 2014 Author Share Posted June 23, 2014 I Found out my self that you have to drag the entity in to the box of the script to get it in. It still does not trigger on the ball though. Quote Link to comment Share on other sites More sharing options...
Rick Posted June 23, 2014 Share Posted June 23, 2014 You have to identify the ball somehow. You can just use it's name if you like. Inside the collision box script you can check the passed in entity "name" key value to see if it's the ball. if entity:GetKeyValue("name") == "Ball" then end Assuming the balls name in the editor is called "Ball" Quote Link to comment Share on other sites More sharing options...
DanceTweety Posted June 25, 2014 Author Share Posted June 25, 2014 This is how it is looking now: --[[This script will make any entity act as a collision trigger. It works best when you set the entity's collision type to "Trigger". This will continuously detect collisions without causing any physical reaction. ]]-- function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) if self.enabled and entity:GetKeyValue("Name") == "ball" then self.component:CallOutputs("Collision") end end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end It does not react on Player what is good but also does not react on ball (this is what the entity is called in the scene). It seem it will not react on a prop. Same happens in the Selective Collision Trigger 1.0 script. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 25, 2014 Share Posted June 25, 2014 I am not sure if this is the issue but try using: Capital N for name GetKeyValue("Name") == "ball" then Quote Link to comment Share on other sites More sharing options...
Rick Posted June 25, 2014 Share Posted June 25, 2014 Also make sure the name is "ball" exactly in your scene. Also how are you judging it's reacting? What do you have hooked up to the collision output to test this? Quote Link to comment Share on other sites More sharing options...
DanceTweety Posted June 26, 2014 Author Share Posted June 26, 2014 This is how the script in the ball looks it is linked in flowchart editor to out of CollisionTrigger.lua script. Script.score = "0" Script.hit_test1 = false Script.hit_test2 = false function Script:Ball_hit1()--in self.hit_test1 = true if self.hit_test1 == true then self.score = "50" end end --[[function Script:Ball_hit2()--in self.hit_test2 = true end ]]-- function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) if self.hit_test1 == true or self.hit_test2 == true then local context=Context:GetCurrent() context:SetBlendMode(Blend.Alpha) --Set blend to alpha so only letters will show context:DrawText("Score: ".. self.score .."",5,150) --Set text and position of text else local context=Context:GetCurrent() context:SetBlendMode(Blend.Alpha) --Set blend to alpha so only letters will show context:DrawText("Score: ".. self.score .."",5,150) --Set text and position of text end end If I put in Player in the CollisionTrigger.lua script instead of ball it works fine. Also try Name instead of name in CollisionTrigger.lua script but then script did not work any more when I tested it with Player. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 I think trigger collision only reacts to character collision. So prop collision won't detect the collision with your trigger. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/collision-r778 Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Rick Posted June 27, 2014 Share Posted June 27, 2014 Collisions react to physics. If your prop has a shape to it then it should react. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 Then why are there different collision types? Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Rick Posted June 27, 2014 Share Posted June 27, 2014 Somewhere Josh listed these out so we can see the setup. Have to find it. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 I posted a link to that above^^ http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/collision-r778 Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Rick Posted June 27, 2014 Share Posted June 27, 2014 You are correct. I missed that. Man it's been a long day. I'll be quite now. We used to be able to control these Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 27, 2014 Share Posted June 27, 2014 Some control would be nice. edit-- I just remembered seeing this post a while back that was talking about how you can change collision response types. I've never gotten it to work though. http://www.leadwerks.com/werkspace/topic/9109-collision-response-types/page__hl__collision%20type#entry69329 Yes, it's just a little convoluted:PhysicsDriver::GetCurrent()->virtual void SetCollisionResponse(const int collisiontype0, const int collisiontype1, const int response); That should really be simplified. Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
DanceTweety Posted June 27, 2014 Author Share Posted June 27, 2014 I have tried making the ball a character instead of a prop allready did not help. Still would not detect it. There must be something in Player prefab that makes it different becouse it is the only thing that is detected. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 28, 2014 Share Posted June 28, 2014 When you changed the balls collision type to Character did you also change its Physics Mode from Rigid Body to Character Controller? Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Rick Posted June 28, 2014 Share Posted June 28, 2014 Note that this will give you a physics shape that you probably don't want for a prop. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted June 28, 2014 Share Posted June 28, 2014 Yeah it will generate the Character Controller cylinder physics which is unwanted in many cases including this one most likely. A work around is to move your entity and then make an invisible entity with character physics that will follow it (using SetPosition() and SetRotation()). Give your entity Debris collisiontype to avoid collisions with the invisible entity(with Character Controller physics) following it. Might not be perfect but that is what I am doing until I can make custom collision responses and it works pretty good. 1 Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
DanceTweety Posted June 28, 2014 Author Share Posted June 28, 2014 No did not change Physics Mode from Rigid Body to Character need it to be ball shaped. Yeah it will generate the Character Controller cylinder physics which is unwanted in many cases including this one most likely. A work around is to move your entity and then make an invisible entity with character physics that will follow it (using SetPosition() and SetRotation()). Give your entity Debris collisiontype to avoid collisions with the invisible entity(with Character Controller physics) following it. Might not be perfect but that is what I am doing until I can make custom collision responses and it works pretty good. This maybe a option I wonder what will happen when I shoot it in a hole though. Quote Link to comment Share on other sites More sharing options...
DanceTweety Posted July 2, 2014 Author Share Posted July 2, 2014 Yeah it will generate the Character Controller cylinder physics which is unwanted in many cases including this one most likely. A work around is to move your entity and then make an invisible entity with character physics that will follow it (using SetPosition() and SetRotation()). Give your entity Debris collisiontype to avoid collisions with the invisible entity(with Character Controller physics) following it. Might not be perfect but that is what I am doing until I can make custom collision responses and it works pretty good. I have try that now Trigger will work it change its Physics Mode from Rigid Body to Character Controller. But then it does not roll off course. When you make object and make that a child of the ball all kinds of strange things happen. I get a giant ball in the scene and it will not detect any way. So seams is no way to get a ball to be detected. Quote Link to comment Share on other sites More sharing options...
Haydenmango Posted July 2, 2014 Share Posted July 2, 2014 Well I have noticed in the past that parenting does more than just move the object in some cases. Moving the Trigger entity using SetPosition() and SetRotation() should work. It can be tedious though. Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
macklebee Posted July 2, 2014 Share Posted July 2, 2014 Your code works fine by just setting the ball's collisiontype to "character". No need to change the actual physics shape.. If Josh would fix the apparent bug with the 'Collision:SetResponse' command, then you could just set the type/response that you want via code. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
DanceTweety Posted July 3, 2014 Author Share Posted July 3, 2014 The program I am making is using the physics engine so making a program to follow the ball using SetPosition() and SetRotation() would be us less. Why cant I like Macklebee is saying set the Collision respons becouse it seems to do notthing at the moment. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 3, 2014 Share Posted July 3, 2014 Sent a PM to you with screenshots showing exactly what I did in my test example. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.