+1 vote

Hi and thank you for your attention, I am still a beginner in c# so please don't hesitate to tell me anything you think might help me.

Context :
I am doing a VR project in which I use a [KinematicBody] moving toward the [ARVRController] for each hands, this allows me to have hands interracting with the physic of the scene.


I want to be able to trigger a function with the object that collide with my Kinematic body as an input when colliding.

My approach

to access the collider, I use the collision property of the [KinematicCollision]
in the script of my hand, I have that (where movement transform is a valid [Vector3]):

KinematicCollision collision = MoveAndCollide(movementTransform);
//when a collision occurs
if (collision != null) {


The KinematicBody.Collider property is of type [Object] and the .name property is part of the [Node] type, so the compiler tell me something like this:

'object' doesn't contain definition for 'name'

My guess

There is probably a way to tell the compiler that the [Object] outputted by collision.Collider inherit [Node] but I can't find the way to do so, please tell me if I am missing something or if I'm wrong.

in Engine by (60 points)
edited by

I found out about casts; but still don't really know how it works,

For anyone wandering the same thing ("convert" the [Object] to a [Node] or any other class) you can use the following syntax:

((Node) collision.Collider).name

with Node as the target class, collision.collider as the [Object] and name as the target property

Please log in or register to answer this question.

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.