Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Limit Physics Body Movement Speed and Direction

    3D Blocks
    1
    1
    298
    Loading More Posts
    • 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.
    • info-creaticode
      CreatiCode last edited by admin

      Description

      When an object is controlled by the physics engine, you can set limits on how it moves using this block:

      5e3066e1-d87a-406e-84be-b1fb8c2d889e-image.png

       

      Let’s go through the 5 input parameters:

       
       

      Speed Limit

      The first input is the maximum speed the object is allowed to move:

      • If the object is moving at a slower speed, then it will not be affected by this limit;
      • If the object is moving at a faster speed, then its speed will be reduced to this value.

      In other words, you can use this block to make sure an object does not move too fast. When an object moves too fast, it might jump to the other side of an obstacle, so the physics engine will not correctly treat it as being blocked by the obstacle.

      If you do not want to set a speed limit, you can leave this input empty or specify a very large number.

       
       

      Allowed Directions

      The next 3 inputs are used to specify whether the object is allowed to move in each of the 3 directions. For example, if we set X to “No”, then the object’s movement along the X axis will always be 0. As a result, it will always stay at the same X position.

       
       

      Object Name

      If you leave the name input empty, the currently selected sprite object will be given the speed limit. If you input an object’s name, then that object will be given the speed limit.

       
       

      Demo

      In this program, we place a box on a plane, then apply an impulse to push it.

      9d5b5577-2351-4bf5-ba26-2c1af087b346-image.png

       

      When there is no limit, the box flies to the right forward direction.

      If we set a speed limit of 111 or 11, the box is much slower.

      If we set the X direction to “No”, then the box would only move along the Z-axis and Y-axis.

      If all 3 directions are not allowed, then the box will stay where it is.

       

      You can play with this project yourself here:

      https://play.creaticode.com/projects/d41dbd54ff5e9cbed1f59c61

      1 Reply Last reply Reply Quote 0
      • First post
        Last post