player turning issues

Blitz3D Forums/Blitz3D Beginners Area/player turning issues

Cubed Inc.(Posted 2011) [#1]
hey, look who's back...again...

I recently have been working on my game's mechanics and I am attempting to make kirby(ssbm model : only for testing) turn to his directions, since right now he only points to them.

The game is in the same perspective in terms of basic gameplay as Donkey Kong County Returns or any other 3d game with 2d game mechanics out there, so I was actually capable of putting together something for turning.

This is what I did, I first created a pivot called pointpiv to guide kirby's turning (I just temporarily made it a cube for testing reasons)...


I then positioned the pivot along side kirby...


After that, I created a variable called transvalue to indicate which side pointpiv would show up on, as seen in the code example above...


then I set up a position changing flag for the pointpiv...


Then the problem crept in...

I used the deltayaw to make kirbys yaw value match that of the pointpiv's


Since kirby's yaw was now matched up with the pointpiv's, I was expecting a smooth turning transition, but instead kirby still remained pointing.

I'm actually sure that the reason that it's not working is becuase the pointpiv is just snapping to different positions rather than moving to them, but I could be wrong.

Is there any way that I can make the pointpiv move between the positions rather that just snapping to them?

I heard that the tformed commands were commonly used for stuff like this, but unfortunantly I can't get any clear information about the function.

can someone please help?


Stevie G(Posted 2011) [#2]
This line is wrong:

RotateEntity TEST_MODEL1,0,DeltaYaw(pointpiv,TEST_MODEL1),0


It should be

turnentity TEST_MODEL1, 0, deltayaw( TEST_MODEL1, pointpiv ) * TurnRate#, 0


Where TurnRate is > 0 and < 1 depending on how quickly you want to turn to the pointpiv.


You also would want the pointpiv to be positioned relative to the TEST_MODEL so instead of :

PositionEntity pointpiv,EntityX(TEST_MODEL1)+transvalue,0,0


It should be something along the lines of ..

tformpoint transvalue,0,0,TEST_MODEL1, 0
positionentity pointpiv, tformedx(), tformedy(), tformedz()

Did you not ask this questions before?

http://www.blitzbasic.co.nz/Community/posts.php?topic=92184#1050143


Cubed Inc.(Posted 2011) [#3]
Stevie G
I honestly don't recall, but the link says otherwise, so I guess maybe I did.

I honestly can't understand your suggestion with the usage of tform functions becuase I am not clear on what tform is. I've checked the forums and the b3d manual and no real concrate explaination was given.

Looking at your code suggestions, I see that you are pretty familiar with the function, so could you explain it to me?

I'd REALLY appreciate it:)


_PJ_(Posted 2011) [#4]
Essentially objects have their own coordinate system, consider a person. A persons head is always above their body meaning in its own coordinate space, the head is at Y=1 and roughly the middle X=0 and Z=0.
The left arm is at X=-1 and the right arm at X+1, at the shoulder height of Y=0.7 or so, again, in the middle of Z=0
If the person is (un)fortunate enough to grow a tail, this would be at their own coordinaet space of X=0,Y=0.5,Z=-1, centrally, but to their rear.

Even if the Person is rotated or moved, the relative positions of these anatomical parts maintain the same characteristics to each other.

TForm commands are used to 'convert' or commmunicate these relative, "personal" coordinate systems into the Gloablised World 3D coordinates, relative to the ACTUAL 3D World Origin of 0,0,0
or the localised coordinates relative to another entity considered as 0,0,0

So, imagine if our 'person' is on a fairground ride. The fairground ride is moving round in a circle.

Therefore, although the head of the person, still has a relation of 0,1,0 to the person itself, to the fairground ride, it has a static relative position, compared to where abouts on the ridfe they are sitting, whilst the GLOBAL WORLD coordinates will be continuously changing as the ride spins them around.

So long as the human remains upright, thoguh, the "Head" will always be at the location of the person's origin with a modifier to the Y axis of +1

If the ride then also turns the person to a prone position pushing their head back and down, but their feet (and tail) upwards underneath them, the orientation of the person is changing, so the Head becomes located at X=0, Y=0 Z=-1, relative to the WORLD coordinates, yet the personal coordinate system still holds that the head is atop the shoulders.



I know its not the best kinda example, and I hope it's not even more confusing.


Kryzon(Posted 2011) [#5]
Imagine the TForm commands as converters between origins (and everytime something is positioned at the origin, it's at '0,0,0').
This also has a lot to do with the Global flag at the end of all Move\Position\Translate\Turn\RotateEntity.

You specify which coordinates (in a certain origin system) you want to know what they would look like using a different origin.

TFormPoint( X, Y, Z, OriginalOrigin, DestOrigin)

The X#, Y# and Z# values you send to TFormPoint are relative to the 'OriginalOrigin' entity (this can be any object, or zero if you want to refer to the 3D world - it still has an origin).
The DestOrigin will specify which origin you want to convert those coordinates to.

If you use it like so:

TFormPoint( 0, 0, 0, Camera, 0)

You would get the actual position of the camera in the 3D world.
Breaking this down:
If we consider the Camera our origin, point '0,0,0' would mean its center, its pivot point. If you had put '0,0,1', you would be referring to "one Z unit in front of the camera, whatever its rotation is".

Now the last argument, zero, specifies which origin we want to know what those coordinates would look like. In this case, the world. So we take '0,0,0' in camera space and receive the equivalent in world space - what position is the camera's center in relation to the world origin?
That's camera's position in global\world coordinates.

If you want to replicate the functionality of the MoveEntity (which moves an entity by offset independently of its rotation), you would use two lines:
TFormPoint( 0, 0, 1, Camera, 0) 
;Calculate the world coordinates of the point that lies at '0,0,1' in relation to the Camera. 
You could use any other value.

PositionEntity Camera,TFormedX(),TFormedY(),TFormedZ(),True ;Apply the calculated new coordinates. 
True is used because we are dealing with world-origin-related coordinates here.
If the Camera had a parent and we didn't specify the True flag, the result would be wrong.


Last edited 2011