![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | stevenotfound001 |
I am new to GDscript and Godot and coding in general. I put the player’s scene and the environment into one main scene. I have a few questions:
- How do I reference an object(CSGbox) from another scene into a player movement script linked to the player (kinematic body) in another scene?
- What code do I use to detect if my player collides with the object referred to in question 1 from the other scene.
I am planning to make a bounce pad/trampoline kind of thing. My code will be something like this: if the player is in contact with the bounce pad, it will change the variable jump speed to 1000 and automatically jump into the air, acting as a launch pad. And immediately change the jump speed back to the original value after jumping.
I don’t quite understand but I think you are talking about collision
did you use “Area3d”
ramazan | 2022-03-08 09:30
You can make global script for your player or you can adress the node which you want to use like:
onready var Bounce-pad-variables = get_node(“/root/Level1/bouncce_pad”) or
onready var Player-variables = get_parent.get_child.get_node(“player”)
For detecting collision you can use signals from Area2D(On the right side of the inspector press “node” and you can pick a signal ).
For specific items you can either use groups
func _on_bouncearea_area_entered(area)
if area.is_in_group(“push”):
or
if area ==“player”
horsecar123 | 2022-03-08 16:03
No, I didn’t use an area node the kinematic body along with the mesh instance, collision shape and the camera, etc. does fine. Is that needed to do this?
stevenotfound001 | 2022-03-09 00:16