How to use Projectile Movement to make my Character jump? - unreal-engine4

I have a brand new blueprint derived from the Character class, and I've added a Projectile Movement Component onto it. I'm having trouble making the character Jump.
The reason why I want to do this is I want to use the projectile movements bounce physics while my Character is in the air, but while they are on the ground use the Character Movement Component to move.
If I set the initial speed of the Projectile Component I can spawn with some forward momentum. However if I try to bind any kind of force or change in velocity to some user input - my character refuses to leave the ground!
My blueprint: https://imgur.com/a/UBuzcq3
When I spawn in the game world, I can see "Jumping" displaying properly but I do not move:
https://imgur.com/a/rGXX3gG
Can someone help me understand why this is happening and how to fix it? I'm fine with C++ solutions as well (I've also tried AddForce function in C++ but have the same problem!)
I have noticed that if I tick "Rotation Follows Velocity" in the Projectile Component then I do get some movement but its super weird and jerky and not at all useable.

Related

Empty Sweep Hit Result On Overlap with projectile

I'm trying to make a projectile shooting system, but the Sweep Result is empty. I need it to see whether or not the projectile hit the bone 'head' and to see the hit location.
I made sure that I have a sweep collision on the projectile movement and the character movement.
Here is the overlapping event with the server event handling the ProjectileDamage:
https://blueprintue.com/blueprint/v9gzb-uf/
(Scroll up to see the OnComponentBeginOverlap Event)
The actual system works, but the sweep result is empty.
Thank you in advance
Physics or Projectile Movement
Use OnComponentHit, not OnComponentBeginOverlap, if using physics or a projectile movement component.
OnComponentHit
Event called when a component hits (or is hit by) something solid. This could happen due to things like Character movement, using Set Location with 'sweep' enabled, or physics simulation. For events when objects overlap (e.g. walking into a trigger) see the 'Overlap' event.
For collisions during physics simulation to generate hit events, 'Simulation Generates Hit Events' must be enabled for this component.
When receiving a hit from another object's movement, the directions of 'Hit.Normal' and 'Hit.ImpactNormal' will be adjusted to indicate force from the other object against this object.
NormalImpulse will be filled in for physics-simulating bodies, but will be zero for swept-component blocking collisions.
OnComponentBeginOverlap
Event called when something starts to overlaps this component, for example a player walking into a trigger. For events when objects have a blocking collision, for example a player hitting a wall, see 'Hit' events.
Projectile Movement
If using Projectile Movement Component, you can also use OnProjectileStop event.
Verify hit is impacting a skeletal mesh
You'll only get a Bone Name in the hit result if you are impacting a skeletal mesh.
Example Project
To see an example of a physics impact and a projectile movement impact hitting a skeletal mesh and returning a bone name, see this example project.
I now figured out how to fix my issue.
I just had to set the the object type, from the character, from 'Pawn' to World Dynamic. Now the projectile also has a Hit Result.

How to return back object position in hinge joint

Hi I'm just new to unity2d, so I have a gameObject that has an hinge joint attached to another gameObject with rigidbody, Im trying to make a Wooden board that will behave like a "seesaw" and return back to its current position when the character is not set foot on it. How can I make it behave like a seesaw thanks!
This is the Original position of the gameObject where the other end of the wood is inclined down.
This should what must happen when my character puts weigh on the opposite end help please.
I recommend in this case to use the "Motor" behaviour of joints:
https://docs.unity3d.com/ScriptReference/HingeJoint-motor.html
So if you set to the "motor" of the joint a little bit of force, it will come back to the start position.
One more recomendation, depending of the force, the joint can "bounce" so I suggest to make some script that sets the motor force only when has interacted with the player, or stop doing the force if it's already on the start position, it's up to you! :D

Unreal Engine 4 - Collider component sweep issue

I have a 2D environment where an object falls (a trap) and a box collider component is moved with a timeline to follow the movement with SetRelativeLocation.
Since the trap is near a wall if I leave the Sweep option unchecked in some cases the character will stuck mid air between the trap and the wall.
Sweep off
If I turn on Sweep this will not happen and the character is pushed to ground correctly but since the collider "slows down" for some frames it seems to be in the middle of the sprite.
Sweep on
Teleport option seems to have no effect on this behaviour.
Is there any way to have the sweep effect with the collider keeping his velocity and keeping the structure as it is with the collider moved by a timeline?
I feel like I'm missing something really simple but I'm losing my head on this.
Thanks!
Since it's 2D, have you tried blocking the input when your character collides? I would add a simple collider in front of your character and when it is overlapped, I'd limit the input in the direction your character goes, ie.:
Character collides right
MoveRight(float Scale): Clamp Scale to (-1.f, 0.f); AddMovementInput(...
Hope it helps!

Unity: Fish with rigid body leaving water

I am making a simulation of some fish in a lake.
I am using rigid body as otherwise they move through the sides. But when they hit into the sides they rotate and then the script I have to set their rotation to 0,0,0 when they leave fails.
Your problem may be occurred by the fact that you are using unity's physics to move the fish but trying to set rotation directly. In this case movement and rotation of the fish are driven by Physics and forces, applied to the object. But you still can affect rotation and position if you reset all forces. Try looking here to learn how to remove forces.
Also when dealing with Physics in Unity, don't mess Update() and FixedUpdate() methods, because it may lead to an incorrect result.
When you say "hit into the sides" do you mean the sides of the simulated lake?
If so, one option might be to set the objects that denote the sides as "kinematic." Then you can detect when a GameObject (such as a fish) collides with it but it won't cause any physics reaction.
(ref: RigidBody)

2d collisions not working properly

Working on a platformer game.
For example, collision without logic will overlap each other when you give velocity to one of them (I solve it with triggers that prevent movement to side where other collider is near).
Now I face an unsolvable trouble. Sometimes my character gets stuck in walls
or cant fall because unseen collision happens.
1 - box collider
4 - box collider
2,3 - triggers
Searching haven't give me structured and right answer, so please, help me solve it.
P.S. Character controller script - https://github.com/rincew1nd/Sleepy-mole/blob/master/Assets/Scripts/character_controller.cs
P.S.S. When I turn off "fixed angle" on character rigidbody2d, all works fine, but physics change a lot and I wanna rigidbody2d with "fixed angle".
I have find an temporary solution for this issue, but it like "invent a wheel", so i still need better solution. Turn on/off fixed angle of rigidbody2d if position not changed for a while and character is not grounded.
http://pastebin.com/Qsm4HACj