No announcement yet.

Replacing a mesh in game, Need to set it rot/loc to same as old mesh

  • Filter
  • Time
  • Show
Clear All
new posts

    Replacing a mesh in game, Need to set it rot/loc to same as old mesh

    I guess the title says it all, noob here

    I have a button which replaces a rotating mesh (blueprint) (spawn from actor class) and deletes other mesh (blueprint).

    But they always spawn with 0,0,0 rotation. I know there has to be an easy way to pass this info to the new mesh.

    use get world rotation node from the original mesh, store the result as a rotation variable, on the spawn actor from class,right click the transform pin and seperate it and in the rotation, plug in that variable
    CEO of Prydetech

    Originally posted by ixicalibur
    Here you go, this is a link to every tutorial you could ever need plus instructions to access all the collective knowledge of mankind: [Super massive awesome link that every amazing game developer uses to instantly learn to be super awesome at making stuff]


      before the mesh is replaced Use get transforms node & store that as a variable.
      And when the new mesh is spawned you can set transforms node using the stored transforms variable as the new transforms.


        Thanks guys, got it working a bit... Still buggy though.

        So the first mesh (on the bottom) spawns on event tick (do once) (skips the destroy for actor who is not there yet).

        When the top button is clicked, The current mesh is destroyed, various stuff to do with vars and button usability, Then actor spawns.

        (IGNORE the unplugged stuff in this screen)

        But then second mesh DOES NOT spawn with correct location.

        However, if you click back on the first (bottom) button, that mesh DOES spawn at the new rotation of the second mesh. Going back and forth only gets the original to take the world rotation

        Also getting console errors about:
        Click image for larger version

Name:	error.jpg
Views:	32
Size:	43.2 KB
ID:	1688593

        Click image for larger version

Name:	rotate.jpg
Views:	47
Size:	220.3 KB
ID:	1688592


          OK, moving on...

          ixicalibur, took a bit to figure out how to split the pin... that got me closer.

          So now the errors are gone. Still same issue though.

          I start map with object #1. (bottom). If I click button to spawn object #2 it spawns but without the rotation transform.

          Selecting #1 spawns #1 WITH correct location. I can go back and forth 20 times. #2 doesn't get rotation, #1 does.

          Click image for larger version

Name:	Almost.jpg
Views:	35
Size:	280.5 KB
ID:	1688640


            can you achieve what you need by simply using "setStaticMesh" node and not destroying or spawning any actors?


              Probably, lol. I'll try it. Thanks


                That was pretty accurate NotSo....

                I've got everything swapping out mats and meshes now instead of respawing and destroying. Another round of cleanup.

                Thanks everyone, the solution was simple but I learned quite a bit.