SOLVED: Object speed in relation to Player speed..

Started by Slasher, Sun 23/02/2014 18:39:08

Previous topic - Next topic

Slasher

Hi,

I have a niggling situation that I wish to resolve.

I have an object (flame torch named otorch) that follows the player (named cCharles) (+- x / +- y) in all 4 of the player loops. I am using the  flashlight plugin. So it looks like the player is carrying a flame torch (otorch is animated).

It all works fine until I increase the players walk speed, it makes the object (otorch) jerk a bit which is a bit off-putting.

Adjusting object move speed in relation to player walk speed is what I am trying to achieve or something that gives the desired effect.

I know I could make another Player View (holding torch) but decided not to.

Here is some code I have used:
Code: ags
function room_RepExec()
{
 if(cCharles.loop==2){
 otorch.Baseline=0;
 otorch.X=cCharles.x-2;
 otorch.Y=cCharles.y-80;
 }
 else if(cCharles.loop==1){
 otorch.Baseline=600;
 otorch.X=cCharles.x-2;
 otorch.Y=cCharles.y-78;
 }
 else if(cCharles.loop==0){
 otorch.Baseline=0;
 otorch.X=cCharles.x+19;
 otorch.Y=cCharles.y-55;
 }
 else if(cCharles.loop==3){
 otorch.X=cCharles.x-24;
 otorch.Baseline=0;
 otorch.Y=cCharles.y-62;
  }
}


Can you assist please?

Thanks



Khris

The method you're using is fine and also the one I would have suggested if you had done it another way.

Maybe we can still fix this though; if you want the player to move faster, you should lower the AnimationSpeed value, not increase the WalkSpeed value, because this will lead to the player starting to glide (or moonwalk, if you want them to move slower). At least in theory, the walk speed is exclusively determined by the player's walk cycle frames, more precisely by the amount of pixels the feet move backwards between frames.

The only problem here is, especially if you have a lot of frames in your walkcycle: an animation speed of 4 might be too slow, while an animation speed of 3 is too fast. If that is the case, you can rectify this by increasing the number of FPS by using, say, SetGameSpeed(60), which allows you to more finely tune the animation speed. Of course this requires that the rest of your game is coded without relying on a fixed speed of 40, otherwise you have to go back and correct all the timed sequences in the game.

Lots of text. Hope it's helpful.

Slasher

Thank you Khris.

I had a feeling it might involve walk speed value and AnimationSpeed value.

SetGameSpeed might be a way to go if I can't get it 100%. Of course I'll have to reset it when player stops moving.

I'll have a tinker around...

QuoteLots of text. Hope it's helpful.
Never too much Khris and yes, very helpful ;)

Thank you

Slasher

SMF spam blocked by CleanTalk