I’m new to Unreal and I have a simple project where i want to make a simple “launcher” mechanism. The mechanism works by having an object on the ground with a particle effect and a capsule component, whenever an overlap is made with the capsule component, it launches whatever is overlapping vertically.
The issue i have is that I can’t figure out how to apply velocity to both a player character (Ideally, specifically whichever is overlapping), and a cube simulating physics at the same time.
I’ve included a Gif showing what I mean, the pusher thing is clearly not throwing the cube up, but launches the character.
I am aware that the reason for this is that my blueprint (as shown bellow) is only detecting a character, but how would I make this work?
have you tried using any of the other physics interactions such as add force and add impulse? those methods can work on all actors that simulate physics.
you can even enable physics when you interact with the item then disable it when done if you like. though you may still want to add in a check to see if its a character and disable physics on landing so they don’t tip over.
in any case i made a little example while playing with different options which is shown in the picture below. in the example you can see i am getting a target via a line trace, then i see if the target is moveable (you could use tags or something as well) to make sure its something i can interact with, next i enable physics. the last bits are the important bit for you to check out, you can either use a impulse which will apply a force all at once, or use add force which will apply a force over time. impulse would be like a explosive bang. add force is more like a rocket or thruster which adds a force at a given rate over a duration, in this case every tick for 0.2 seconds (probably not a great way to handle the close but o well).
I’d go for a similar solution as ThompsonN13 went. But instead of a linetrace I’d use a Capsule component for an overlap event. From that capsule you can get a component array with "[get overlapping components][1]"
It would be better to look into the collsion settings of the capsule to only overlap with the object collsion types you want to, otherwise objects without simulating physics also get taken into acocunt.
Use the “Add Force” function with the tick function in a for each loop of the component array. The Add Impulse would only be good for an instant, one time event, because it adds a fixed amount of energy for every execution. So on a higher frame rate you would get much more Energy applied. Add Force takes frametime into account.
On Begin overlap you can open the gate and on End Overlap with a check on the “[get overlapping components][1]” if it has a “[Valid index][2]” of 0, if not you can close the Gate.
Also if you like to know a little perfomance trick: You can use “[Set Actor Tick Enabled][3]” instead of the Gate to control if the functions get executed. You can uncheck “Start with Tick Enabled” in the Class Defaults. But make sure you don’t have any other funtions in the Blueprint that would need the tick