Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

2D Rigid Body stuck at corner of 2 static wall at 90 degree
Started by kevinluk Jun 23 2018 04:49 PM

6 replies to this topic
physic rigid body corner stuck
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

kevinluk

[GLOBAL: userInfoPane.html]
kevinluk
  • Observer

  • 3 posts
  • Corona SDK

Hi guys,

 

I am having an issue with a rigid body getting stuck whenever it reaches the corner of four walls surrounding it. 

 

It is a rigid body with four static body wall, and gravity is manipulated by the following script:

 

physics.setGravity( 40 * event.xGravity, -40 * event.yGravity )

 

The script works fine, but the rigid body becomes unresponsive to the gravity (i.e. stay in position) when it reaches the corner. It is a rectangular rigid body, and I've tried changing the bounce of everything from 0 to 0.2.

 

Any thoughts will be appreciated.

 

Cheers,

Kevin 



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,748 posts
  • Corona SDK

That is not enough for us to help.

 

Can you use this as a starter and make an example demonstrating the problem?

 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/05/dodi.zip

 

Then attach the modified and renamed demo of the issue here in a zip file:

 

1. Clicking 'More Reply Options'

2. Doing this:

attaching_files.jpg



[TOPIC: post.html]
#3

kevinluk

[GLOBAL: userInfoPane.html]
kevinluk
  • Observer

  • 3 posts
  • Corona SDK

Thanks roaminggamer,

 

Here's a demo of my problem. I only added the object in scene 1.

 

Let me know if there's anything else I should provide.

 

I do hope there's a silly mistake in there.

 

Cheers,

Kevin Luk

Attached Files



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,748 posts
  • Corona SDK

I'm sorry I goofed up.  I gave you the wrong link.

 

I meant to have you use this file to make a barebones example:

 

https://github.com/roaminggamer/RG_FreeStuff/blob/master/AskEd/askEdStarter.zip

 

I must have been answering another question and pasted the wrong link here.

 

I'll transfer your code to my starter, then take a look.



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,748 posts
  • Corona SDK

OK.  I transferred the code, and found no issues.

 

Try running this:

 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/06/physicsProb.zip

 

1. The original code could only be accurately tested on device.

 

2. Testing it in the simulator won't give you reasonable results because of the nature of the simulated accellerometer event.

 

3. To simplify testing this I wrote a bit of code to fake a randomly moving phone.

 

Question 1: Have you been testing on device or simulator?

 

Question 2: Have you been adding print statements and looking at the log ouputs?  

 

It seem to me you were assuming xGravity and yGravity would be values between -1 and 1, when in fact they may not be (especially on the simulator).

 

Anyways, the code looks fine to me.  Try commenting out my fake bit, re-enabling your code, then run it on a device.



[TOPIC: post.html]
#6

kevinluk

[GLOBAL: userInfoPane.html]
kevinluk
  • Observer

  • 3 posts
  • Corona SDK

Thanks, Roaminggamer, and sorry for my messy codes.

 

I have run it on a device and the problem persists. 

 

Just to confirm I have uncommented line 52-58

local function tiltGravity( event )

 

and commenting out line 61-79

local function fakeTilt( event )

 

timer.performWithDelay( 250,

 

The android device I have access to is quite old: Samsung Galaxy S4 on Android 5.0.1

 

I used "copy to device after build".

 

Corona console looks normal, keeps printing different values after the player got stuck in the corner. (log attached)

 

Below is a video I've just put on youtube that demonstrates the problem.

https://youtu.be/8U0kZcxYXjo

 

Perhaps a device specific issue?

 

Thanks,

Kevin

Attached Files



[TOPIC: post.html]
#7

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,748 posts
  • Corona SDK

1. That is odd.

 

2. No need to apologize for anything.

 

3.  I'll take a look on Monday. I am just replying so you know I saw the post.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: physic, rigid body, corner, stuck