![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Hecks567 |
hi, so I’ve been playing around with godot for a few months now and been trying to work out some simple architecture for my concepts and mechanics.
at the moment I’m working on a test project in 2d.
I’m trying to mimic the original gta game , a top down game with driving but also with on foot style gun play.
now I’ve successfully got my player to enter the car, but exiting the car isn’t working,
i used this YouTube video to as a baseline guide https://www.youtube.com/watch?v=7VzBHbG8sqo
func enteringCar():
if Input.is_action_pressed(“enter_vehicle”) && car_zone == true :
var hidden_player = get_parent().get_node("Player")
hidden_player.active = false
$Camera2D.make_current()
active = true
func leavingcar():
var vehicle = "."
var hidden_player = get_parent().get_node("Player")
var newLoc = vehicle.global_transform.origin - 2*vehicle.global_transform.basis.x
if Input.is_action_pressed("enter_vehicle"):
hidden_player.active = true
print("exiting car")
active = false
print("de-activating vehicle")
hidden_player.global_transform.origin = newLoc
the issue seems to be var newLoc = vehicle.global_transform.origin - 2*vehicle.global_transform.basis.x and hidden_player.global_transform.origin = newLoc
it says invalid index “global transform” on base “string” now i know or have some idea that within the leaving car function the global transform isn’t recognised, I’ve tried using various alternatives
I’ve tried tweaking it and even put a position2d node at the side of the car and tried the get mouse position then to unhide the player model at the mouse position. I’ve tried making the player a child of the car, and tried rewriting the script to place the player at an area node.
so I guess I’m asking for a bit of help writing the leaving car function for 2d. my player is already hidden and the car is active, but no amount of experimentation seems to get the player to unhide, i will admit that positioning and placement are not really things i’m experienced on