Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sidoku |
I want to make a chemical reaction with water and lava particles (RigidBody2D) so that it becomes obsidian. And I want them to change their sprite and collision to another shape entirely. From a circle to a cube for example. I couldn’t find any other explanation of merching 2 RigidBodys together into one. When I put the particles in my scene, I duplicate it to over 100 pieces, so my idea is that when they merch it becomes less each time.
This is my script so far with the Water Rigid Body:
extends RigidBody2D
export(String, FILE, "*.tscn") var WaterParticleCollisionShape2D = ""
export(String, FILE, "*.tscn") var WaterAreaCollisionShape2D = ""
var static_mode_switch_legth = 2
func _integrate_forces(state):
if state.linear_velocity.length() < static_mode_switch_legth:
sleeping = false
func _on_WaterParticle_body_shape_entered(_body_rid, _body, body_shape_index, _local_shape_index):
if $WaterParticleCollisionShape2D.collided_with(body_shape_index): visible = false
if $WaterParticleCollisionShape2D.empty(): queue_free()
if $WaterAreaCollisionShape2D.collided_with(body_shape_index): visible = false
if $WaterAreaCollisionShape2D.empty(): queue_free()
pass # Replace with function body.
The body shape entered function haven’t solved the problem, but maybe I haven’t writen the correct input.
This is the script for the lava rigid body:
extends RigidBody2D
export(String, FILE, "*.tscn") var game1_target_level_path = ""
var static_mode_switch_legth = 2
func _integrate_forces(state):
if state.linear_velocity.length() < static_mode_switch_legth:
sleeping = false
func _on_Area2D_body_entered(body):
if not body is Player: return
if game1_target_level_path.empty(): return
get_tree().change_scene(game1_target_level_path)
pass # Replace with function body.
I don’t know if it even is possible. If it is possible, please let me know. Thanks.