|
@@ -272,7 +272,12 @@ get full autocompletion on the player variable thanks to that cast.
|
|
|
|
|
|
player.damage()
|
|
player.damage()
|
|
|
|
|
|
- or ``assert()`` statement::
|
|
|
|
|
|
+ You can also simplify the code by using the ``is not`` operator::
|
|
|
|
+
|
|
|
|
+ if body is not PlayerController:
|
|
|
|
+ push_error("Bug: body is not PlayerController")
|
|
|
|
+
|
|
|
|
+ Alternatively, you can use the ``assert()`` statement::
|
|
|
|
|
|
assert(body is PlayerController, "Bug: body is not PlayerController.")
|
|
assert(body is PlayerController, "Bug: body is not PlayerController.")
|
|
|
|
|
|
@@ -282,6 +287,7 @@ get full autocompletion on the player variable thanks to that cast.
|
|
|
|
|
|
player.damage()
|
|
player.damage()
|
|
|
|
|
|
|
|
+
|
|
.. note::
|
|
.. note::
|
|
|
|
|
|
If you try to cast with a built-in type and it fails, Godot will throw an error.
|
|
If you try to cast with a built-in type and it fails, Godot will throw an error.
|