How to make an object bend in the opposite direction as it moves into Unity - unity3d

I need to move a 3D object like in the "Run sausage" game.
https://www.youtube.com/watch?v=CQa5PUlSfwk
There, as the character runs forward, its body kind of bends backwards, in the direction opposite to the movement.
In particular I do a simulation of a tornado in Unity, but when I want to go forward to the upper part of the tornado moved back, and after 1 second reaches the lower part ("legs")
Any suggestions would help me. Thank you

The movement like in the Sausage Run game can be achieved easily by using animator controller specifically Blend Tree. Watch this tutorial is you are not already familiar with these
https://www.youtube.com/watch?v=E-zQw4GabKw

Related

Why does using PhotonRigidbody2DView give 'elastic' movement?

I'm currently using photon pun 2 to learn simple 2d multiplayer.
Using PhotonRigidbody2DView is giving an 'elastic' movement to the player. The player goes forward a bit and then returns to the original position.
Here's the video:
https://youtu.be/HgFVsofVZcQ
Why does this happen and how do I solve this?
I tried using PhotonTransformView and PhotonTransformViewClassic but it is giving weird results. The players go inside each other and when one player collides the other, the other player starts jittering.
So I decided to use PhotonRigidbody2DView instead. Now the players don't go inside each other and the jittering is also not happening but the 'elastic' movement problem is happening.
This happens because the remote client uses the velocity of the rigidbody to reproduce the movement of the character is does not control. This makes it a bit independent from the lag but for arcade style movement (where direction changes are immediate), this doesn't work all that well.
Solutions to this depend on what you actually need. Networked objects combined with physics can be tricky to get right. For PUN 2, we didn't implement a solution to this case and assumed you'd tweak the PhotonRigidbody2DView as needed.
The Smooth Sync package in the Asset Store seems to do well and is a plugin to PUN 2.
Alternatively, the newer Photon SDK "Fusion" should do better and is state of the art as networking solution.

Spawning blueprint does not spawn anything (UE4)

Here's a problem: my goal is to have a ball game with obstacles. I made two obstacles (cubes with triggers) and the spawner code does not spawn them - nothing at all. It does compile without errors, but just does not work. These blueprints are part of the track class (the track the ball is on). Here is the code: (obst amount = 7 - the code before it works fine - its linked to event tick)
Here are the obstacles: (no code in them)
Here is the track:
I'm using Unreal Engine 4.26.2
If it is showing up in the outliner, but you don't see it here's what I would try.
First, unplug your X and Y location. Manually input something you know is right in front of the player.
If you can see it after that, start printing the the coordinates of the spawn location. If those look right and you can't see it still, try spawning a regular cube instead. If you could see the cube but not your obstacle, then I'd check the obstacle BP. In that case it's likely either the scale of the mesh component or it's set to be hidden in game.
Sorry I know this isn't a definitive answer, but I don't have enough reputation to comment instead.

How can I implement input movement?

I am new to UE and trying to make very simple game to learn the engine.
This is how the game looks
I want the player to be able to move the cube(PlayerPawn) left and right only.
This is my script to move the pawn.
But when I go left or right it also rotates. How can I fix this? How can I implement input movement while the pawn simulates physics?
You're applying floating pawn movement on a non floating object? That just doesn't seem right does it?
If you want to use custom movement just setup a collision component (BoxComponent in your case maybe?) And apply forced with SetForce/AddImpulse or SetLinearVelocity.
Also might be worth your time looking into the Character blueprint clasd that comes with lot's of premade movement capabilities

How to change the shooting accuracy?

I am making an FPS game using unity 3d, I've a problem in the shooting accuracy script. Can you tell me how I can change it with a single script that shoot the bullet and include the shooting accuracy and equipped to the gun, please?
If you are currently using a raycast, you should have no problem.
If you are spawning a sphere and thrusting it forwards, I suggest you use a raycast.
Raycasts go in a completely straight line. Bullets follow gravity, and quickly fall to the ground.
You don't see bullets, they move too fast. Raycasts are invisible.
When it hits something, it sends you back the information you need. If you make the sphere go too fast, it might glitch through objects.
You can learn about raycasts here.

Dragging a Sprite (Cocos2D) while Chipmunk is simulating

I have a simple project built with Cocos2D and Chipmunk. So far it's just a Ball (body, shape & sprite) bouncing on the Ground (a static line segment at the bottom of the screen).
I implemented the ccTouchesBegan/Moved/Ended methods to drag the ball around.
I've tried both:
cpBodySlew(ballBody, touchPoint, 1.0/60.0f);
and
ballBody->p = cgPointMake(touchPoint.x,touchPoint.y);
and while the Ball does follow my dragging, it's still being affected by gravity and it tries to go down (which causes velocity problems and others).
Does anyone know of the preferred way to Drag an active Body while the physics simulation is going on?
Do I need somehow to stop the simulation and turn it back on afterwards?
Thanks!
Temporarily remove the body from the space.
If you want the object to have inertia when you release it, that's a different story. The cleanest way is to attach a fairly stiff spring between the ball and a temporary sensor body that moves under the control of your finger. When you let go with your finger, the ball will retain whatever kinematics it had while you were dragging it. Be sure not to remove the ball from the space in this case.
You aren't updating the velocity of the object when you aren't using cpBodySlew(). That is why it falls straight down.
A better way to do it is to use a force clamped pivot joint like the official demos do to implement mouse control. http://code.google.com/p/chipmunk-physics/source/browse/trunk/Demo/ChipmunkDemo.c#296