Download

Character Spawning with Incorrect Forward Vector

Hey everyone, I’d really appreciate some help with a doubt I’ve got. I’ve got a revive mechanic in a game I’m making (as part of my class; I’m a student), which works the following way:

Consider that character (C) is dying, and character (R) is going to revive it.

  1. Before C dies, its class and transform are shared with R.
  2. When C dies, it is deleted from the game.
  3. When R uses the revive mechanic, a new C is spawned using the class and transform R has stored with it.

The problem I currently have is that the forward vector of the new C is always (1,0,0), whereas the old C died with a different forward vector. What do you guys think could be the problem?

When you’re sharing the class and transform info, try printing the transform info from R after it has been stored.

Hey Stormrage. I did do that and the values are correct, which is what is puzzling.

Well, that is strange. Is it a multiplayer project? If so, one option would be to see if the same happens if you run it in singleplayer mode.

Could you paste some code? So that we can better help you find the issue.

Yes, I’m sharing the relevant blueprints now.

It’s a single player game. I’ve posted some screenshots for you to take a look at, so hope you can help me out using those!

Since the transforms match at the time of spawn operation, the rotation values should be going through. Right after spawn, do you see it rotating towards the x-axis, like maybe for an instant?

Oh and btw if your character is facing in the correct direction, but it’s just the Control Rotation node giving incorrect results, it’s probably got to do with the AI Controller not having finished initialization. You can see the correct results by setting a small delay after Event Begin Play for your AI Controller. So if that is what’s causing the issue, I’d suggest using the pawn’s Get Actor Rotation instead of Control Rotation.

Hi again. I don’t have AI Controllers in my game since I haven’t been taught how to use them and it’s a tight schedule. All my characters work based on their event graph. I did try using the Actor Rotation instead of Control Rotation but that didn’t work either.