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. Dominance Group in 2D Physics

Dominance Group in 2D Physics

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 908 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

    After 2 objects collide, the 2D physics engine calculates where they would go based on their physics properties, such as mass, speed and restitution. In general, the object with a faster speed or larger mass would tend to “dominate” the interaction, pushing the other object away while maintaining its own course. However, we can change that using “dominance group”.

     

    Set Dominance Group

    We can set the dominance group of any sprite using this block:

    48ae38e1-2cf2-4ccc-832f-3f0c3a381802-image.png

     
    The new group number can be any value between -127 and 127. By default, every object has a dominance group of 0.

    When two or more objects interact with each other, the object with a higher dominance group will have a “stronger weight” on the result. For example, if 2 objects collide, then the one with a higher dominance group would maintain its course, while the other object will be bounced away.

     
     

    Demo

    In this demo project, there are 2 sprites, one beach ball and one basketball. When these 2 balls collide, and if their dominance groups are both 0, then both of them bounce back:

    b1.gif

     
    However, when we set the dominance group of the beach ball to 1, it will not bounce back:

    b2.gif

     
    You can play with this project or modify it here:

    https://play.creaticode.com/projects/65144b7b78dfe33adbb6e2d8

    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