Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. Setting Physics Properties for 2D Objects

Setting Physics Properties for 2D Objects

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 741 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

    Introduction

    Every 2D object has 3 important properties: density, friction and restitution. After adding a sprite to the physics world, its properties will be set to some default values. You can further update these properties using the block below:

    b2f39c47-bb3c-46e3-89e3-3810f2fd497e-image.png

     
     

    Density

    The density controls how much substance an object has. Specifically, an object’s mass equals its density times its size (total area). When you have 2 objects of the same size, the object with higher density will be heavier. On the other hand, when 2 objects have the same density, the larger one will be heavier.

    Note that from physics laws, heavier objects won’t fall faster, but they will “win” when colliding with a lighter object. In the example below, these 2 balls have the same size, but the blue ball’s density is 10 times that of the green ball:

    bb.gif

     
    All fixed objects are assumed to have an infinitely large density no matter what you specify.

    When a dynamic object’s density is 0, the physics engine will assume it has an infinitely large density. The object won’t respond to forces or gravity, but you can still set its speed. Basically, it will behave like a “movable” object.

     
     

    Friction

    When 2 objects are touching each other, and one of them moves relatively to another, there will be a friction force that tries to prevent this movement. The friction property controls how much friction force exists between 2 objects: a value of 0 means no friction (perfectly smooth surface between them), and larger friction values mean stronger friction forces.

    The average friction between the 2 objects will determine the friction force between them.

    For example, the slope has a friction of 0, the box on the left has a friction of 100, and the one on the right has a friction of 0. The friction force is keeping the left box staying where it is, and the right box slides down the slope:

    b7.gif

     
     

    Restitution

    The restitution controls how bouncy an object is. When 2 objects collide, we take an average of their restitution values. If the average is 0, then these 2 objects will not bounce back, but rather stick together. If the average is 100, then they will bounce back at the same speed as before they collide.

    In this example, the box has a restitution of 100, and the 2 circles have restitution values of 100 and 0.

    bc.gif

     
    The average restitution of the blue circle and the box is 100, so the blue circle will rebound at full speed repeatedly.

    The average restitution of the green circle and the box is 50, so the green circle will lose half of its moving speed after each rebound.

     
     

    Physics Properties of the 4 Walls Around the World

    When you initialize the physics world, 4 walls are added around the stage to keep objects inside. You can set the physics properties of these 4 walls using the following block:

    b8dbd314-22b6-41e1-8315-e7e3c6698c4e-image.png

     
    Note that the walls are fixed, so their density is assumed to be 0. You can only set their friction and restitution values.

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode