This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:guides:beginners:physics [2018/02/13 20:47 (7 years ago)] – ↷ Page moved from guides:beginners:physics to en:guides:beginners:physics iarwain | en:guides:beginners:physics [2024/11/17 04:48 (5 months ago)] (current) – sausage | ||
---|---|---|---|
Line 15: | Line 15: | ||
In order for physics to act on an object, the object needs to have a body. Let's add one to our hero: | In order for physics to act on an object, the object needs to have a body. Let's add one to our hero: | ||
- | < | + | < |
[HeroObject] | [HeroObject] | ||
Graphic | Graphic | ||
- | Position | + | Position |
Scale = 2 | Scale = 2 | ||
AnimationSet = HeroAnimationSet | AnimationSet = HeroAnimationSet | ||
Line 40: | Line 40: | ||
</ | </ | ||
- | The type is box and that means the collision area is a box shape surrounding the object. The part is also set to solid. That means that the object will not be able to pass through other solid body parts. | + | The type is '' |
Run that and you'll see our hero fall right through the floor. So that's good. The physics body is working. But we need to get the platforms solid too. | Run that and you'll see our hero fall right through the floor. So that's good. The physics body is working. But we need to get the platforms solid too. | ||
- | < | + | < |
[PlatformObject] | [PlatformObject] | ||
Graphic | Graphic | ||
- | Position = (0, 570, 0) | + | Position = (-400, 270, 0) |
Scale = (54, 2, 0) | Scale = (54, 2, 0) | ||
Repeat | Repeat | ||
Line 65: | Line 65: | ||
</ | </ | ||
- | Notice the slight difference from the hero body. The PlatformBody is not dynamic, so it won't be affected by gravity. But the PlatformBodyPart is set to solid. This will allow the hero to collide with the platform without it falling away. | + | Notice the slight difference from the '' |
- | But the two won't affect each other until you set collision flags. | + | //But the two won't affect each other until you set collision flags.// |
First, set the flags on the HeroBodyPart: | First, set the flags on the HeroBodyPart: | ||
- | < | + | < |
[HeroBodyPart] | [HeroBodyPart] | ||
Type = box | Type = box | ||
Line 79: | Line 79: | ||
</ | </ | ||
- | The SelfFlags is a string that descibes | + | The '' |
- | Now set the PlatformBodyPart flags: | + | Now set the '' |
- | < | + | < |
[PlatformBodyPart] | [PlatformBodyPart] | ||
Type = box | Type = box | ||
Line 95: | Line 95: | ||
Run the game and our hero will land and stay on the floor. | Run the game and our hero will land and stay on the floor. | ||
- | But he kind of hangs into the floor. | + | Our guy lands and stays on the floor. |
- | < | + | You can turn on physics debug mode if you want to see the bounding boxes around the objects. Turn on the physics debug with: |
+ | |||
+ | < | ||
[Physics] | [Physics] | ||
AllowSleep | AllowSleep | ||
Line 104: | Line 106: | ||
</ | </ | ||
- | You can see the boxes that surround the bodies. The hero's object | + | You can see the boxes that surround the hero and platforms. That is because they have bodies. |
- | + | ||
- | < | + | |
- | [HeroAnimationSet] | + | |
- | Texture | + | |
- | Pivot = center | + | |
- | FrameSize = (32, 32, 0) | + | |
- | StartAnim = HeroRun | + | |
- | HeroRun | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round tip 60%> | + | |
- | The step above may not be required. Needs to be checked. | + | |
- | </ | + | |
Run that up and you should get the following: | Run that up and you should get the following: | ||
Line 128: | Line 116: | ||
---- | ---- | ||
- | Next, [[guides: | + | Next, [[en:guides: |
- | {{section> | + | {{section> |