It possess but after the vehicle respawn it won’t move. Any idea how to fix this?
SPORTSCAR BP
MY PLAYER CONTROLLER BP
It possess but after the vehicle respawn it won’t move. Any idea how to fix this?
SPORTSCAR BP
MY PLAYER CONTROLLER BP
Hey there @BeastNectus! So your widget that houses the buttons likely has a reference to your car/player pawn in there somewhere right? It’s likely that it’s set when it spawns. However you’re spawning a new car after this, so that reference likely needs to be updated, or alternatively you could destroy the old UI and let the car spawning create a new one for you.
To go into specifics I’d have to see what your buttons are bound to.
You got it.
So basically what’s happening is that when the widget spawns, it looks for a sportscar actor then sets that reference. Problem is that the old UI is trying to send those commands to the old sportscar ref that was there when it was created. You can handle this one of three ways.
Or
Or
Which one would you like to go for? I can write up an example for whichever one you’d prefer and you can probably adapt it.
I like to see the examples each of those for me to get ideas what to do, If it’s okay to you.
I gotcha, let’s run through #3 first since it’s my biggest recommendation. Since you’re working on mobile, the less things you have to garbage collect the better. If it works out we won’t bother with the others, because they are just roundabout ways to do the same thing. I’d only do 1 or 2 if my game really called for it.
So the fun part is all you really change is just not destroying the car. You just teleport the actor to the respawn point and set it’s transform. This will make it inherit the transform of the respawn location, so make sure that’s pointing forward (it probably is considering you’ve been using it like that), and that’s it! Your old UI will remain and the car hasn’t changed. Now if you have car damage and things like that, you may need to reset those values.
Try it out, and let me know how it goes!
But how can I do that if my CARSREF is class object? Is there another method to do that using my carsref classobject? I think your method is only working for object reference.
I set it to class object because I made some blueprint that will show the cars using the class objects. I have 3 cars only.
Sorry! The other image didn’t seem to send.
the return pin from your original spawn will return the actor you created. Use this to set the car reference.
That is… odd. All that was done was the actor was moved, it shouldn’t effect the camera’s relative distance to the vehicle. Is it clipping something?
What do you mean clipping sir ?
This is all the nodes behind my respawning the car if its flip and not moving.
MyPlayerController BP
SportsCar BP RespawnCheck Function
SportsCar BP EVENT GRAPH
I debug it the reason why its close its because the vehicle scale becomes 1
The vehicle becomes big and that’s why the camera is so close.
This is the scale when its respawning the car.
But I’ve set it my car default scale to 0.5
The problem here is that after respawning the scale of my car becomes 1 instead of 0.5. Any idea to fix this ?
Ahhh yeah, that’s an easy one. So right now it’s inheriting your Respawn Location’s scale. We’ll just break the transform and use a Set Actor Location and Rotation node instead. (you could also just break the pin on the transform one, but this seemed clearer)
Thank you it fix my problem. You’re so nice. You explain every step should do. Thanks again.