So here the problem is your event.
You should have an event (Say an input action event, “Event SpaceBar” or something) Spawn a BP of an actor, then use a dispatcher to run an event with all of this code on the actor object. The dispatch message should include the spline as an input so you can carry over the reference with an output
Here are some links if you need a refresher or you don’t know how dispatchers work:
Will show up on the spawn node; you may need to right click and refresh the node.
And i need to add both on begin Play?
Not necessarily. It really depends on how the conveyor is supposed to work.
If the player comes over and drops an actor on the conveyor, there’s no need to spawn a new one, you’d add an existing actor to an array and calculate a new offset. The offset does not even need to be in the actor.
Depending on the desired complexity, you could create an X number of invisible dummy anchor points moving along the spline. When the player drops an item, we’d attach it to that dummy.
Or use actual spline mesh components that can deform. Dropping something onto a spline mesh, snaps the actor to it. This way, the actor does not care about any offset, it rides attached to a dummy that follows a spline anyway.
That sounds really good. My plan was to create a track treadmill using the code. The player drops the pallet on it and the physics do the rest. It becomes a logistic simulation.
Is that a good idea or is the physics too unreliable?
Thanks that helped me a lot. Now the assembly line works. What I’m still missing is the rotation. They don’t turn in the curve. Tried to insert the Rotation Along Spline.