Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Wrong collision sensing "event.contact.isTouching"
Started by zombiexp2010 Mar 02 2020 03:59 AM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 63 posts
  • Corona SDK

Collision listeners:
local function sensorL_Collide(event)
	if event.contact.isTouching then
		sensorL.collide = true
		if event.other.type then sensorL.groundType = event.other.type end
	else
		sensorL.collide = false
		sensorL.groundType = "None"
	end
end
local function sensorR_Collide(event)
	if event.contact.isTouching then
		sensorR.collide = true
		if event.other.type then sensorR.groundType = event.other.type end
	else
		sensorR.collide = false
		sensorR.groundType = "None"
	end
end
-----------------------------------------------------------------------------------------
Enter frame:
if not sensorL.collide and not sensorR.collide then
	isGrounded = false
else 
	isGrounded = true
end

print(tostring(sensorL.collide).." "..tostring(sensorR.collide).." "..tostring(isGrounded))
------------------------------------------------------------------------------------------
sensorL:addEventListener("collision", sensorL_Collide)
sensorR:addEventListener("collision", sensorR_Collide)

"sensorX.collide" and "sensorX.groundType" - additional non-system variables

I know about "tutorial/games/nonPhysicalCollision/index.html" but I think this a very bad approach to invent such crutches while there is already a system that should work.

Time between sensor falls from "ground" to "platform" is few frames while iterations go three times every frame by default. 

Any ideas? Something missed? Something missunderstanding? Please?

 

ALSO <pre> and <post> collision event is NOT WORKING if object.isSensor = TRUE but works great if an object IS NOT SENSOR!!! 

Attached Files



[TOPIC: post.html]
#2

zombiexp2010

[GLOBAL: userInfoPane.html]
zombiexp2010
  • Enthusiast

  • 63 posts
  • Corona SDK

Now the problem is partially solved:

1. Sensors deleted because post-collision event is not working for sensors

2. Post-collision event is firing for main body and <isTouching> works great

3. Comparing <event.y> coordinate with main body bottom. If true -> collision happens with ground

 

very bad because I can have a circular located rotating sensors for some advanced cases...



[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,246 posts
  • Corona SDK

Good to hear you've solved your problem at least partially.

Now, sorry, but what are the remaining issues that you are facing?




[topic_controls]
[/topic_controls]