Jump to content

Recommended Posts

Posted

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 smile.png

 

 

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.

Posted

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"

Posted

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.

Posted

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?

Posted

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.

Posted

Some control would be nice. smile.png

 

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.

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Posted

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.

Posted

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.

  • Upvote 1

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Posted

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.

Posted

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.

Posted

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.

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...