Hit Actor overrides Location

Hi - I’m trying to add Location and Rotation animation to selected object. Ideal if I could play animation for few objects and then play it in reverse (only for some of them).

Problem: After selecting another object it takes Location from previously selected mesh

Video: - YouTube

Blueprint:

This has a fairly simple reason.

You set your actor and move it. However you are doing that inside of your character. This means whatever you do it will always trigger the same code. So if you while one actor is moving select another one it will screw up the reference and stop moving that. You always take the current actor location as default value so when you call this function on an object and then switch to another it will stop playing for the first one (It will stay in it’s current position) and play the second one. If you now call the first one again it will start at it’s current position.

Fairly simple fix. Set a bool while it’s updating and disallow changes while it’s moving. If you need multiple objects to work at the same time make a function out of your timeline. Call that with the current actor and it will finish.

Or if you already use 4.7 I would highly suggest using an interface and an actor component. Do the movement inside of this actor component and just call the interface event so the actor itself handles this code. Like that it will by itself make sure it won’t be interrupted and you can more easily keep references to the original position and stuff like that.

I hope this helps.

Cheers! :slight_smile:

Erasio - Thank you very much for help :slight_smile: I tried the first fix and it works very good but I got into trouble trying to make a function of the timeline (also haven’t found any tutorial on this subject).
So I tried the interface solution (according to this video: - YouTube) but I also failed.

I’ve changed new blueprint to something simpler (but after clicking on the actor it doesn’t give me anything). It only worked on static meshes which already were part of BPMove Blueprint. Could you write/show me what I’m doing wrong?

Oh you won’t need to set the actor in this case. It will just be self (or if you use a component it will be owner).

The simple interface will be enough in your character.

And for your receiving BP… Well try get owner. If it doesn’t work give me till this evening when I’m sitting in front of an engine.

Edit: oh and btw you get the actor and cast that to a component. That will always fail. You need to get the component or just use the interface… It should pick it up if the component implements it and just do nothing if not.

Thx - I wasn’t sure about cast but added it only to get SET variable.
I tried both HitActor (self in BP) and HitComponent (Get owner) but both did nothing. Feel free to take as much time as you like :slight_smile:

Alright so it’s not as convenient as I hoped for.

You have to get the component itself if you want to call the interface like this:

And if you then want to modify or change the actor you attached your component to you will need to use “Get Owner”. For example if you want to get the name of the actor you attached it to do this:

Sorry again for the late response.

Cheers! :slight_smile:

Sorry I notice only today your answer - thank you very much :slight_smile: Could you clarify a bit what is this custom component class (‘TestComponent’) (I would guess it is a part of ‘Test Interface’)?

Oh no. Sorry. I thought it’d be more obvious.

“TestComponent” is a “Actor Component”. You can choose this one when creating a new blueprint and it’s basically code you can add to any actor in your level with one drag & drop (or by duplicating that actor). Basically just a piece of code you add to make it do something.

Ok finally I had time to finish this - The last version works :slight_smile: the only difference I had to make was to connect Hit Actor directly to Message Interface target (without components by class). Thank you very much - I wouldn’t be able to do it without you :slight_smile: