Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I need help with some code!

So I am planning on making a replica of the game Sand Balls. How do I do the sand break script? I have asked many for help with no success. You can find some examples of Sand Balls on YouTube. Anyone please help! I have no script for the sand yet because I don't even know where to start. Any help is appreciated!

As your finger moves, it breaks the sand. How do I do this?

Comments

  • You will first need to know the position of your touch in World Space.

    There are two ways I see it happening.

    One being you make a mesh which is the sand and do not make triangles in a radius from your touch.

    Another way I see is that there are a lot of small cubes which can not move and they are destroyed within a radius of your touch.

    I think the second method will be very CPU intensive so better try the mesh.

    Sorry if it does not work.

  • jtok4jjtok4j Member

    Greetings,

    Something like this asset on the Unity Asset Store might be helpful: https://assetstore.unity.com/packages/tools/physics/impact-deformable-4799

    Allows for one to reshape the object, which might match your need with sand.


     Keep on Creating! 


    Justin of JustinTime Studios (http://unity3d.expert) 

  • WarpWarp Member
    edited May 2020
    1. Get the position of the Touch.
    2. Use Camera.ScreenPointToRay to turn the touch position into a Raycast.
    3. If the Raycast hits the sand, apply a Decal at the normal the Raycast hits.

    Its not exactly the same, but it should give you an idea of how to do it.

    The decal can be transparent, the background, a colour, whatever you want. There are probably some better ways to do it, but this is a pretty simple one that should work.

    Also, have some system to check how close decals are to each other, to prevent them from overlapping everywhere.

Sign In or Register to comment.