Rpg style movement

Blitz3D Forums/Blitz3D Programming/Rpg style movement

RiverRatt(Posted 2005) [#1]
I have bin playing with this code for a couple weeks now. It is diablo style movement using a target entity that the player_mesh points at and if is far away the player_mesh moves to it. I have two versions the first is a no media and has bin posted in the code archives. The second one has
the ninja animation (for a place holder) from pacemaker.
I have not done much with 3d animations yet so if your have time I would apriciate any helpful coments, or if you know a better way to do this style movement I would like to here about it.
Some problems I am having are...
Jumping is difficult to achieve becouse pointentity seems to override any other movement comands.
With just a plane and the ninja I'm getting about 30-45 fps.
I don't know the polycount of the ninja but it seems to me I should be getting a better frame rate. So some tips on achieving optimal perfomace would be nice.



and the real code



Thanks for any help!


jfk EO-11110(Posted 2005) [#2]
you may use translateentity for jumping, and right after pointentity you may use a

Rotateentity guy,0,entityyaw(guy),0


RiverRatt(Posted 2005) [#3]
I now have 75-105 fps by using a lower graphics setting and by using vwait flip false. It looks about the same but twice the frame rate. I also have the player jumping to any place the mouse pointer is, including up onto boxes and stuff. He even walks on verticle surfaces. I think I want to build on that. The only problem is making it look right.
As is the player is pointing at the marker and is straight up if on leval ground, however on a verticle surface he will its angle is all haywire.

So my Idea to fix this is to use rotateentity like above, but how can I find the 90 degree angle to the surface he is jumping too?


fall_x(Posted 2005) [#4]
I'm not sure that I understand what you're asking, but DeltaYaw() or DeltaPitch() might be what you're looking for.


RiverRatt(Posted 2005) [#5]
What I am asking is a for a way to make the player stand on picked verticle surfaces. Imagine the player that follows the mouse (like in the 1st sample code I posted}. Then I have a large cube that is pickable, standing twenty or thirty feet tall, representing a wall of a building. Now when the player jumps onto that wall I want the player to ajust to the suface by standing 90 degrees to it and look the same as if he is standing on the ground. I'll post screen shots in a little while to show what I am talking about.


RiverRatt(Posted 2005) [#6]
This picture demonstrates what I am talking about.
http://www.urbanposters.com/item~p~8320~pnid~847~nid~445.htm


fall_x(Posted 2005) [#7]
Ow, a bit like in Ratchet & Clank where you can move up some buildings and stuff? I'm not sure how to do that, but I think you might be able to do it by always doing a linepick straight down from the player's location, and then use AlignToVector yourplayerentity,PickedNX(),PickedNY(),PickedNZ(),2
It won't work with 90° angles, because you pick straight down, but that could be easily solved by creating a small ramp.
So instead of sharp angles like this :
  |
__|


you'd make them softer like this :

  |
_/


You'd have to make sure you always move the player relative to the current angle.

That could work :)


RiverRatt(Posted 2005) [#8]
Good Idea, I'll give that a shot.
Thanks


fall_x(Posted 2005) [#9]
Oh, just one tip on using linepick : do it after you do updateworld. If you have some kind of gravity that is pulling down on the player every frame, your player could be a very little bit beneath the object you're trying to pick, but if you set up the collisions correclty, this won't be the case after updateworld.


wizzlefish(Posted 2005) [#10]
I have a question:
If you have multiple UpdateWorlds in your main loop, which one should you place it after?


fall_x(Posted 2005) [#11]
You shouldn't have multiple updateworlds in your main loop, because it would slow down everything. You'd best do something like this :
UpdatePlayers_Before() ; player movement etc
UpdateEnemies_Before() ; enemy movement etc

UpdateWorld()

UpdatePlayers_After() ; linepicks, position shadow at linepick coordinates, etc
UpdateEnemies_After() ; linepicks, position shadow at linepick coordinates, etc

Renderworld()
You can store the results of the linepick in the player's type if you need to use it in UpdatePlayers function.

In the UpdatePlayers_After() function, you can also compare the LinePick with the player's height to know if he's floating somewhere or not - I use this for jumping and gravity... When the player jumps, set player\jumping to true, and use this to make sure he can't keep jumping even when in mid-air like you can do in the castle demo. When the height of the player minus the linepickheight is very small, set it to false.
In your UpdatePlayers_Before(), you can check player/jumping - if it is true, increase player\dy# which is the amount you make him move down each frame. If it is false, set player\dy to a very small value (or 0, but I found a small value worked better).
This is all a bit off topic, but I think you might find it usefull :)

But if you do need multiple updateworlds, put it either after the last one, or after the one that comes after your player movement routines (where you apply gravity).


SabataRH(Posted 2005) [#12]
It's a nice start for point and click code... the real mastery happens when you have objects and things in the pathways... Assuming the play surface isnt always flat.

I've been working on such a plotter for sometime now but with little results i'm afraid. I got the best results by using a node system but this isnt the best way of doing it as maps can become large and node chking can become tidious on the resources..

If you happen along a method please share! :) as will I.


RiverRatt(Posted 2005) [#13]
So far with no collisions set up there are two things that happen with objects in the way. If the object is pickable the player steps on it and the height is adjusted becouse the player is set like this
If MouseDown(1) Then 
		FlushKeys 
		PositionEntity marker,marker_X#,marker_Y#,marker_Z#
		Playerwalking=1 
	Else Playerwalking=0 
	EndIf
	
	If EntityDistance(player_mesh,marker)>5
		PointEntity player_mesh,marker
		MoveEntity player_mesh,0,0,2
		PositionEntity camera,EntityX(player_mesh)-22.5,EntityY(player_mesh)+65,EntityZ(player_mesh)-22.5 
		PointEntity camera,player_mesh
		Playerwalking=1
		
	Else Playerwalking=0 
	EndIf
End Function



the result is, if its just like some steps or a ramp he walks up them and looks ok but the players height is ajusted as soon as that point is picked rather that when he reaches the step.
The second is that when the object is tall like a building and is pickable, but the player walks up it taking the shortest path posible.(ninjas are so lazy) The good thing about this is that usualy becouse of the camera veiw you end up picking a side of the tall object and the player walks up it verticly, but on his side which looks goofy.


I guess, in a way thats how this code works, but only one node. You klick a point on the grid and the player moves to that point. I could see it being expanded on to be able to click several points and get the player to move to each point. Then expanded further to use a pathfinding algorithm
to make the point automatic. Thats a ways off though.