I work at a 2d game in Unity and i have some troubles . My character have a hand which extend when i press E . If the hand collide with an object the hand will stop there and my character will be able to drag that object . If i press R the hand will contract in the character . The problem is that if i jump and in the same time i press E and my hand collide with an object the character remain in air and i dont want that . I want my character to fall on the ground and my hand to remain in the same position . Important : My hand is a child of the Character and if i add a force to the player will affect the hand . And another problem is that i dont know how i can make my hand remain in the same position if it collide with an object . only the part that is attached to the body to move down along with the character .
I tryed to parent and un-parent the hand but that seems to dont be a good ideea. Maybe i shoud make my palm of the hand another object ?
Related
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.
So, lets say my character has the ability to push "movable" objects. This is alredy implemented and working as desired.
But I want to make the characher be pushed back if he tries to push an object that is hitting a wall or an immovable object, is there a way to see if my add impulse had any effect?
Or a best way to do is some ray casts on the movable object boundaries to see if is touching any other thing?
For characters you can use Launch Character. It's like adding velocity giving a specific direction. Add Impulse is intended to be used with Objects that simulate physics.
Just Launch the Character to a direction opposite the direction it's touching. You can use Dot Product between Character Velocity and the Object Face (forward).
I have a character which is controlled with physics stuff like Spring Joint and Constant Force (The character is active ragdoll).
I want to stick the character's legs to the ground and when it is bent left and right, the entire character doesn't move on the ground.
What is the way to achieve it ?
Currently I use Fixed Joint on both legs with Constant Force but still the character moves around when there is sudden force on upperbody.
As you can see in the gif.
So, I'm trying to make a simple RPG game using Blender and Unity. I would like to have an empty object to be used as a weapon holding position parented to my right hand bone so that I can switch weapons in and out and they'll be able to animate along with my character by being the child of the empty position. The problem I am having is that I can't get the empty position to be a child of the specific right hand bone, only the armature. Is there a way to make this work? Also, if this isn't a good procedure to accomplish what I am trying to do, please enlighten me with the proper way, I'm kind of a noob, thanks.
If you have assigned your bones correctly on your character, you should be able to add additional game objects into the joints of the character, ie. Swords, shields and other cool things.
Then you can use this code to quickly fetch specific defined bones:
_playerAnimator.GetBoneTransform(HumanBodyBones.LeftHand);
Which gets the bone transform.
Here is a quick snippet of the assigned bones using a PlayerAvatar on character.
I have this third person character blueprint in which I'm trying to hide the character mesh if the CameraVisibilitySphere component overlaps the character. It actually works, but only if the character moves.
If simply I move the character close to an object, rotate the camera so that it collides with the object and gets closer to the character, the mesh won't disappear. But if I just move the character a bit, no matter in what direction and so that the sphere still overlaps with the character, Is Overlapping Component returns true as it should and the mesh is gone.
When the mesh is not visible, without moving the character, and I rotate the camera so that the visibility sphere doesn't overlap anymore, nothing happens. If then I move the character, the mesh reappears.
I tried using OnComponentBegin/EndOverlap and I've also coded it, but nothing changes, it shows the same behaviour.
The code I set the sphere with is this:
CameraVisibilitySphere = CreateDefaultSubobject<USphereComponent>(TEXT("CameraVisibilitySphere"));
CameraVisibilitySphere->SetupAttachment(FollowCamera);
CameraVisibilitySphere->SetSphereRadius(12.0f);
CameraVisibilitySphere->SetCollisionProfileName(TEXT("Actor"));
CameraVisibilitySphere->bGenerateOverlapEvents = true;
CameraVisibilitySphere->OnComponentBeginOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterBeginOverlap);
CameraVisibilitySphere->OnComponentEndOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterEndOverlap);
BTW the character's capsule is set to generate overlap events and to overlap with the camera.
What should I do to make this work? And, most importantly, do overlap events get called on child components of the same actor?
I'm new to Unreal, so I still don't know the environment very well.
Overlaps created in the parent are inherited in the child. You might try getting your Camera and do a MultiLineTraceByChannel, break the hit result and cast the hit actor to your character, then in your character, fire off the code to hide the actor with a custom event.