+1 vote

im trying to implement shape shifting, i made some code that takes the mesh node of the raycast collision point and sets the players mesh to the enemy mesh but when it activates the player mesh turns just invisible

here are the parts of the code that does the shifting:

onready var rayCast = $RayCast
onready var mesh = $mesh
func _physics_process(delta):
if rayCast.is_colliding():
    var target = rayCast.get_collider()
    if target.is_in_group("enemdr"):
        var msh = target.get_child(1)
        mesh.mesh = msh

i tried printing msh and it did print the name of the mesh instance node used in the enemy so what is going on?

Godot version 3.5.1
in Engine by (25 points)

You should choose better names for your variables and nodes to keep your scripts more organized.

1 Answer

0 votes
Best answer

You are setting the mesh of the MeshInstance to a node. If the following line is a MeshInstance:

target.get_child(1)

Then change it to:

var msh = target.get_child(1).mesh
by (731 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.