I’m making a system that change the camera target to the one its pressed, but I’m using global variables for this, so i am using one to take the targeted object name, another to make a position X variable (e.g: “GlobalVariableString(Target).X()”, and the same thing for the Y position too, so this will be “Player.X()”, or, “Player.Y()”. But when i put that variable on the lerp function, It says that i have to use numbers, even if the final result of all of that variables is a number. Someone help pls.
You cannot access an object’s properties this way. You have to explicitly write it’s name out.
The only way you might be able to get around it is by using an object group, iterate over all the group’s objects in the scene and see if it’s name matches the global variable. Not great for performance.
Another way would be to have a camera target object, and use the sticker extension to attach it to the pressed/clicked object, and have the camera focus on that camera target object instead. This is a much better in terms of performance and the number of events you’d need to create.
But you can’t just use a string and concatenate it with .X()
. It doesn’t work that way.
But i concatenated the string using global variables, and it worked with the text box, but because the variable is a string i cannot use it as a variable to pick the player’s position, so i just have to turn the string into a variable (or something, i’m not sure what’s the name) to make the lerp function read it. But i used another method to do what i was trying, but thanks anyway, sorry for taking your time.
Are you saying you used something like Set the text of TextObject to ToString(GlobalVariableString(Target).X())
, and the text box had the X position (a number) in it??? I fail to believe this.
After i posted this i deleted the global variables, i tried to reproduce but i can’t now, i think i was just seeing wrong, sorry for that.