So I’m a noob at unreal engine and I’ve been having trouble with this and I feel like it should be simple. Anyway what I want is on a button click, a mesh will spawn. Right when it is spawned I want it to travel to the player controlled character and then float near his hand. If someone can help me with this, that would be fantastic. Thank You
You need to add a ( for instance ) simple sphere mesh to the player hand. Not visible in game, but attached to the hand, so it moves with the hand.
When you’re ready, spawn the new actor and move it to the world location of the sphere actor.
You could use a timeline or vinterp if you want this to happen gracefully.
So how exactly do you reference the sphere mesh you put on your character? I can’t seem to find a way to reference the sphere in the level blueprint, or do I put all this information in the actual character blueprint?
Hi - I’m not on a machine with the engine right now so can’t check, but one of two things:
You may be able to ‘getplaycharacter’ cast to your kind of character, then access the various components
Or, yes, do the whole thing in the character BP, would be pretty normal to do that also.
So the object spawns in the right place, but it’s still not moving to the sphere I put on the character BP. What exactly am I missing?
Are you getting your world/local positions mixed up? I assume MoveComponentTo uses a relative location and you’re giving it world.
Pull a pin from SphereOnPlayer and look for GetRelativeLocation
Ah ok. I changed that, but it’s still not working. The projectile spawns, but stays in the position it spawned at. What else could be the issue?
Here’s how I did it:
I spawned a cube, and then used a timeline to move it to the location of the FP gun. Very similar in concept.
The two things I’m wondering about your setup are:
I think you’re doing something weird with MoveComponentTo, because you’re mean to give it a component reference, which you aren’t doing. ( You should be able to just grap a compoent from the list and plug it straight in, but have an ACTOR spawned in the world, which is not a component ).
If you the projectile is from the projectile class it wants to move the moment you spawn it, which is not going to help you ability to get it where you want it.
( I know it says ‘sheep’ in class type, but it’s actually a cube, just a left over from another example I did ).
Also, to avoid you head banging for a few hours, it you want to move it from somewhere other than 0,0,0 you have to put the start location in a variable and give it to the lerp as that variable ( ie, fixed ).
Using a GetActorLocation plugged into the lerp will give you just more weirdness…
So I tried your example out. It’s doing the same thing unfortunately. It’s spawning, but not moving. I really don’t know if it’s something in the actor that is spawning, something in the timeline, or the object it is supposed to move to. It’s a little weird and a bit frustrating. Any idea what it could be?
I also wanted to say Thank You for helping me. I’m sorry if I’m being annoying or anything, I’m not that great at Unreal yet and just needed help. So thank you
No worries. Have you tried spawning a different actor, like just a plain cube?..
So I tried switching different actors and it kinda works the way I want it to. It moves toward me now, but it moves to a spot in mid air above the player and moves around with the player. I want it to move to the hand, stay in that relative location, and move with the player whenever they move. Is this something I change in the timeline or is this something different overall?
Once you’ve moved it to the hand ( I know we’re not there yet… ) then you need to attach it to a socket. Otherwise you have to spend the whole time moving it on tick, not pretty.
I really don’t know what you have going on, the strange movement still sounds like you’re getting world / relative and Add / Set nodes mixed up. To be clear this should only be WORLD location and SET.
If you want to put just the trouble areas in a small project and give me a link I’ll take a look. You do that like this:
Make a new project, no starter content
In you old project right click on anything that needs to be transferred and choose ‘asset actions → migrate’ and choose the content folder of your new project.
Then you can just zip the new project folder ( from windows explorer ) and put it on google drive, or wherever.
So i actually tried the move to component node again, and it’s actually working now! Thanks so much for your help.
I only have one more question. Is it possible to make the object that moves toward the player hover or play an animation when it’s attached to the player?
Sure it is, but that’s a separate thing really
The thing you spawn can be a BP, and that BP can play an animation when it’s near the player. It also, most likely, would be a particle system ( I’m imagining magic casting etc ).