I am trying to achieve the following effect;
https://i.stack.imgur.com/nLSzy.gif
regardless of the location or rotation of the actor.
So far I have managed to move actor location from one side of the box to the other downwards in the direction I have my camera facing by creating the component in the appropriate local location and using its coordinates in this way;
https://i.stack.imgur.com/gcL7x.png
However, I cannot cope with the rotation, for many hours I have been messing with different nodes, it always works maybe up to two rotations and with next the camera spins and ends up in the wrong place.
I even tried changing actor rotation towards the component on the underside of the actor, or rotating this component and copying its worldrotation to the actor, but the effects are the same!
Related
So, i am trying to create a flat conveyor that a block will sit on and move, but i want to have it be able to turn, so i cant use rigidbody.moveposition, ive tried using addforce, but i cant get it to work properly without using impule or velocity change, because then it makes the ore roll (they are cubes). my most recent attempt was using velocity, but im not sure how to make it keep its old velocity when changing corners so it doesnt screw it up.
.
If this doesn't make much sense, here is a better explanation, i am trying to create a conveyor system on a grid, where each slot has a direction, and an cube travels along it, whenever the cube reaches a turn, i want the cube to keep moving forward a short distance so it doesn't just immediately change directions and go along the new conveyor, because this way, it will immediately change and will sit on the edge of the conveyor, and not keep moving in the direction.
edit: i currently have it working, my now issue is the cubes will bounce when touching the conveyor, so they wont stay flat against the conveyor, i can fix this by constricting all the cube rotation, but then it will sometimes freeze the ore on the conveyor, not allowing it to move.
since you didn't provide code, I don't know what you are trying to do, so I will give my own solution:
object.transform.position = Vector3.MoveTowards(target.transform.position, endpoint.position, Time.deltaTime * speed)
Then, when it collides with it, it can turn off this script, so it stays at the end.
target is what you want to move, endpoint is where you want it to end up.
Make endpoint a gameObject, and put it at the end of your conveyor, so the objects will move toward, and it will look like a conveyer.
Long-winded question out of the way, I'll provide a diagram of what I am going for:
The red square represents the character, the blue rectangle represents the camera, the green dot represents the center of the "stage", and the black circle is the stage itself.
What I desire is to essentially lock the player's movement around the "center" of the stage, so that anytime you move left or right you are more or less rotating around said center. However, I also want the player to be able to move forwards and backwards to/from the center as well. Keep in mind I want the camera to always stay directly behind the player. I have tried many different methods, and the latest is the following:
I took a default actor, attached a spring arm, attached a child actor to that (gets possessed to become the playable character), attached another spring arm, and finally the camera to that. I then added the blueprint code to the first spring arm so that it was the one being controlled by the left/right controls. However, upon hitting play, the only thing that moves is the camera, and it can only move forwards and backwards.
I'm admittedly pretty new to Unreal Blueprints, so any help would be appreciated.
Alright, I figured it out.
Here's the setup needed if anyone else wants something similar.
For the player themselves, you'll need something like this:
The important thing is to center the root mesh where you want to rotate around. The spring arm's target arm length will be affected for the player mesh movement, giving the illusion you are physically moving the character. The second spring arm isn't necessary unless you wish to have more control over the camera to player distance.
For the rotation Blueprint, you'll need this:
The target is whatever you named the root mesh. (Mine was called Center) Drag and drop it from the hierarchy.
For the forward/backward movement, you'll need this:
The target is what you named the spring arm. (I left mine as the default "SpringArm") Again, just drag and drop it from the hierarchy.
Adjustments in Project Settings:
Yes, my inputs are backwards from what you'd think. I felt it was quicker just to reverse the inputs instead of adjusting whatever was causing the movement to be backwards in the first place. (It's probably just the sphere orientation.) Also, you'll notice I have the w and s inputs set to 5 or -5 instead of 1 or -1. This is due to the fact the movement was slow otherwise. I'm sure there's a fix that doesn't involve changing the input axis scale, but honestly I won't really have a reason to alter the values at any point in my project. If it ever comes up where I do need to, I'm sure there's a bypass to change the values from within blueprints anyways.
End result:
End Result Video
If I remember correctly, child actor components are a bit different from other components in that they are transformation independent, that is they do not update their transformation when their parent component moves around.
I find it a bit strange that you would separate your player actor and the camera component. Normally, the player "pawn" contains the mesh and camera components for one player.
I would suggest you do the following:
Create a player actor (e.g. a "pawn" or "character" class)
Create the following component hierarchy:
Root Scene -> Spring arm -> Skeletal or static mesh -> spring arm -> camera
Your root scene is the green center in your drawing. You can then basically use the blueprint you already have to rotate and move your player.
I am using Unreal Engine to create a puzzle game. In this game, the player has to pick up a chair/table and place it on a pressure plate in another part of the room in order to unlock a door.
When play testing, picking up objects causes my character to slide back. Once the sliding starts, there is no way to make the character stop sliding. I suspect that this issue may be caused by the object's collision volume entering the character's. However, when I release the object, my character keeps gliding backwards even though by then, the object's collision volume is out of reach.
On my character's blueprint I have locked rotation on all axes, so that it won't randomly start rolling backwards after picking up an object. This solves part of the issue but there is still the gliding that just won't stop.
I am new to UE and I have no idea what may be causing this issue. If you have any previous experience in this or simply want to chime in, please do!
Another alternative fix is to lock the rotation of the collision component in the default pawn that you have or to increase angular damping.
To do so, open the default pawn blueprint and under the physics section, then constraints, lock rotation in the X, Y, and Z axis. Or increase angular damping.
Dont know why this is happening exactly unless we see the actual settings you are using and the BP but when you pick up the object , disable its physics and collision and when you put it back enable it after a delay of 0.5 or 1 second . Hope this helps.
My problem is that I have a rigid body with a spherical collider and once it starts moving (rolling) it never stops.
I have read other answers here which state that changing the drag (angular and normal) is the answer to this problem but I must be doing something wrong somewhere else. I have been experimenting with this for hours and cant find a solution.
I have moved the drag to a million, still moves but very very slowly. I have moved the angular drag to a million with similar results. I have set the sleepThreshold to a high number. This didnt seem to do anything. I tried changing the friction on the terrain.
I placed the ball on a flat, horizontal plane for all of these tests and applied an impulse to start it moving. It has never come to a stop yet.
There are times when it reaches a certain velocity and then stutters like it is about to stop and then it starts moving at a constant velocity forever, I think I can visibly observe the shift from deceleration to constant velocity. It doesnt make any sense to me at all.
It is my assumption that the ball should stop eventually and that unity, being so advanced, would handle this easily but its possible that I'm missing something due to being so new.
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