Updating the Collider Box
-
Prerequisite
Introduction
As described in Detecting Collision, you can use a collider box and some light rays to detect collisions. Sometimes, you will need to update the collider box, using the following block.
The “Update Collider” Block
You can set some additional parameters for the collider using this block:
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0ffedb82-38cc-419d-a463-ccb564a12246.png" width="900" style="">
Collider Dimension X/Y/Z
By default, the collider is sized to cover the player object exactly. However, you can change its size based on your needs.
For example, if you want the collider box to be extra thick, you can update the “Y” size.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/50852149-83a5-4e2b-a56e-b755a5ea05d0.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
Collider Z Offset
You can also set a different Z offset for the collider box. For example, if your avatar is running a swimming animation, then you need to update both its collider box dimension and Z offset.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f5f6da1a-71a7-4bba-81b5-f7383e54b6e2.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">
Sensing Range X/Y/Z
These 3 inputs allow you to set the length of the rays in these 3 directions. For example, if your avatar is never going to move sideways, then you can set the collider in the X direction to 0, so no collision will need to be checked in that direction to reduce some computation time.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/72949f58-1a0e-4811-935e-8257819befb4.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
Collider Box Color
Lastly, you can use a different color for the collider box, if the yellow color does not provide a great contrast.
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/043faf6e-3a75-4b20-bd1a-a3c833925984.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
-
I CreatiCode pinned this topic on
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