bruce965 / godot-gpu-cellular-automata

GPU-accelerated cellular automata template in Godot (OBSOLETE: could be done in better ways in Godot 4)
MIT License
16 stars 2 forks source link

player collision #2

Closed zhaishengfu closed 3 years ago

zhaishengfu commented 3 years ago

Hello, do you have any ideas for doing player sprite collision with sand simulation?? for example:

  1. when character jump into sand, sand will fly to the sky
  2. when character trap in sand, it will move slowly
  3. hwen character move in sand, sand will change

The way I can think is read character pixel from viewport, and when the pixel is character, do collision logic. But I can not think clearly the logic

bruce965 commented 3 years ago

You could use the CPU to read the pixels from the particles simulations, and use the CPU to integrate the "particles to player" (point 2) collision logic. As for the "player to particles" (points 1 and 3) collision logic, you could pass the player position from the CPU to the shader, and do your computations on the GPU.