Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Physics does not work
Started by AkioSarkiz Nov 14 2018 02:06 PM

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

AkioSarkiz

[GLOBAL: userInfoPane.html]
AkioSarkiz
  • Observer

  • 23 posts
  • Corona SDK

I import a map from a tile. And in a tile I add physics to objects. A player in the code loa. But for some reason they do not interact when they contact. What is the problem?
link google disk: https://drive.google.com/drive/folders/1Im8GiQQr2SwlsLIvdxZdVNdio_fccbJa



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,380 posts
  • Corona SDK

Physics works fine.  You're making some mistakes.

 

Your map group doesn't have the same position as the player group.  Also, it looks like you scaled it.

map.xScale = const.scaleMap;
map.yScale = const.scaleMap;
map:translate(-150, -100);

The groups containing bodies must all be aligned (have the same position) and you can't scale physics bodies directly or indirectly.



[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,380 posts
  • Corona SDK

In a nutshell, the way you are handling your camera code is wrong.  I hope that gives you a place to start.

 

Explaining how it is wrong and how to fix it is a bit too time consuming for the budget I have for helping right now.

 

Let me just say, all objects and groups should be in a camera group (the parent of all world content including the player).

 

Then, when you move the player, an enterFrame listener should do this:

1. Determine how much you moved the player since the last frame (player's initial position should be center of screen)

2. Move the camera group the exact opposite of that amount.

 

This is the most basic of camera algorithms and will keep the player centered.



[TOPIC: post.html]
#4

AkioSarkiz

[GLOBAL: userInfoPane.html]
AkioSarkiz
  • Observer

  • 23 posts
  • Corona SDK

Let me just say, all objects and groups should be in a camera group (the parent of all world content including the player).

 

 

But how?
I added them to one game group. But now the player and the physical objects themselves are moving.
 

this is code

        sceneGroup:insert(player);
        sceneGroup:insert(gameLayer);

Let me just say, all objects and groups should be in a camera group (the parent of all world content including the player).



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,380 posts
  • Corona SDK

I'm sorry, but I really can't help.  While I can resolve the problem and eventually explain it, that is a lot of work.

 

I suggest one of these approaches:

 

Take  A Timeout and Learn More About Fundamentals

You're trying to make a game as fast as you can, which is cool, but this is what happens sometimes. 

 

You run up against the wall of not-knowing-how-a-thing-works.  The only self-solving solution to this is to:

  1. Take a time out and learn how the basic camera works.  i.e. Stop working on the project and go write some standalone experiments for the sake of learning.
  2. Extend that learning to including adding bodies and and seeing how they interact.
  3. Examine the tiled library you're using and learn how to add the player directly from Tiled using some kind of builder to make the player after reading the level data.  i.e. Don't let the tiled library do all the work.
  4. Apply your leanings to the tiled library by adding camera code to the builder or the tiled library itself.

There are no shortcuts to learning game development concepts.  Using Tiled and a library is a bit of a cheat unless you wrote the tiled library.  When I say cheat, I mean you're cheating yourself by bypassing hard-earned lessons.  

 

I don't mean to be negative here, just realistic.  Making games is hard work.

 

 

Get An Experienced Partner

Alternately, you might try to partner up with someone who has more experience.  That way s/he can help you out in cases like this.

 

Wait For Another Answer

I'm not the only person here.  There are plenty of smart folks, one of which who may have the time and knowledge to help.  I can only answer for myself here.

 

 

Pay Someone?

This is an unlikely solution, but you might also consider paying someone to set you up with an environment and docs so you have a solid foundation.

 

The tools you're using are solid, but general.  You need some specific solutions, which is where you're getting stuck.  Paying someone for their time may be the only way to get help that you can grok.

 

 

Whatever the case, keep plugging away.  Try, try, and try again.  You'll get there eventually.



[TOPIC: post.html]
#6

AkioSarkiz

[GLOBAL: userInfoPane.html]
AkioSarkiz
  • Observer

  • 23 posts
  • Corona SDK

Thank. I will wait for a response from other users.
I think that learning to create games is necessary when creating a game. So there is an experience and better absorbed.



[TOPIC: post.html]
#7

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,637 posts
  • Corona SDK

Hmm, perhaps, but maybe not one that involves tile maps and third party libraries. If you don't know the basics it can be very difficult to integrate your code with someone else's who may have a completely different style to tutorials/examples you've worked with so far.


[topic_controls]
[/topic_controls]