PDA

View Full Version : Locking player movment in 2D a Axis.



TheSpaceMan
11-13-2009, 01:33 PM
Solved.

I am not sure of the name of the function i am looking for.

In essense I want to limit the player to moving in a 2d plane (X,Z but not Y for instance).

I guess the easiset way right now, when I am in a trial face, would be too force the Pawn to a predetermined position, say Location.Y = 8.0f;

But since Location is a const and can't be changed, I need to find where this is set and possible extend this function to do it the way i want it to be done.

Or just if there is a SetPosition( ... ) function
Does anyone have a suggestion that might help?

Thanks.

Solution:
SetLocation will set the location of the Pawn. input for the SetLocation is a Vector.

As for where to catch updates.
simulated event Tick(float DT)
{
super.Tick(DT);
}
was the answer.

Mysterial
11-13-2009, 02:21 PM
Or just if there is a SetPosition( ... ) function


It is SetLocation(). See Actor.uc

TheSpaceMan
11-13-2009, 02:29 PM
Yeah sorry. Got it working. Thanks.

TheSpaceMan
11-13-2009, 03:05 PM
What would be the best function to put the actuall call in. Right now it's in calculate camera because that is the only one i know get's called.

Is it safe to overload Tick and how would i make sure that the rest of the code that relay on it gets called as it should?

TheSpaceMan
11-13-2009, 04:01 PM
Ah found it as well.

simulated event Tick(float DT)
{
super.Tick(DT);
}

Solid Snake
11-13-2009, 04:19 PM
It isn't a good idea to use Tick to set the player location per frame. If you want to restrict movement in certain axis, just ensure that the player has no chance of actually getting a pawn to move like that.

Check the PlayerWalking state within PlayerController and see how to UE actually moves the player pawn.

TheSpaceMan
11-13-2009, 04:29 PM
It isn't a good idea to use Tick to set the player location per frame. If you want to restrict movement in certain axis, just ensure that the player has no chance of actually getting a pawn to move like that.

Check the PlayerWalking state within PlayerController and see how to UE actually moves the player pawn.

Thanks. I will look into that as soon as I get the crosshair / hitarea back in sync. The reason behind the move is also that explosions etc should force a player sideways but not backwards forwards, so even if I do reset the controllers, states, there could still be other issues knocking the players in the wrong direction.

Allar
11-13-2009, 04:51 PM
Could set up a rigid body constraint

eosteric
11-13-2009, 06:18 PM
It is SetLocation(). See Actor.uc

is there a reference list somewhere of every class and function we can call on? I've been looking everywhere for something like that, now I don't know what's available to use so it's difficult

TheSpaceMan
11-13-2009, 06:53 PM
Like rekomended above, if you have visual studio and open the Actor.uc in the Engine/classes folder. You got a members dropdown list that help a lot when you have a rough estimate of the name of the function. The problem is genericly named functions. Since almost everything got a Rotation and Location those words are terrible in searches. And since you might call it a lot of diffrent things, in theory for a rotation the function could be look at, setRotatation, setYaw, SetPitch, SetRoll or SetYawPitchRoll.

The only list i found wasn't that helpful, it showed what class each class is based on, aka the super class. But gave very lite detail on what each class actually contain in the way of functions.

It would be nice with something simular to .chm thats part of the the DirectX SDK documentation. Where you have every keyword,function, class in a nice list.

mightyenigma
04-22-2011, 07:28 PM
RigidBody constraints don't work on Pawn physics. They work on rigidbody physics.

mightyenigma
04-24-2011, 04:46 AM
I had mixed success using SetLocation:

in the Tick function for the Pawn:
local vector xFix;

if (abs(Location.X) > 5)
{
xFix = Location;
xFix.X = 0;
SetLocation(xFix);
}

I added a conditional with some elbow room because SetLocation resets some things about the Pawn, possibly including its Base (object it counts as its floor). I ran into tiny bugs when it did this all the time instead of only when the pawn has definitely slipped off axis by a few UU.

I wish there were some documentation about the side effects of each function in the Engine. It does so many things without telling you.