Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,789 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Drifting and Aiming problems #201530
04/09/08 19:11
04/09/08 19:11
Joined: Oct 2007
Posts: 116
S
sydan Offline OP
Member
sydan  Offline OP
Member
S

Joined: Oct 2007
Posts: 116
I have two problems. I'll start with the easiest. I have a normal FPS with a player that accelerates when you press w and deaccelerates when you let go. Simple except the player 'drifts' after you release the key.
This is the code I'm using to deaccelerate:

if(my.relx > 0.2)
// where my.relx is the relative movement value in the x direction
{
my.relx -= 0.5;
}
if(my.relx < -0.2)
{
my.relx += 0.5;
}

you would expect the player to atleast drift backwards, but this is not so, it continues to drift forwards. I have tried adapting all the values but it doesn't see to have any affect, whats more this 'drift' seems to happen randomly, sometimes it stops as needed, others it keeps going slowly in the same dirrection with a value of a round 0.15, positive.

Also my other problem is a turning one. In my game I have oppponents that, if they sense you, will spin to face you. Originally I simply set the enemies 'pan' value to the dirrection needed to face the player but this is jerky and unnatural so i used a piece of code that finds the difference between the dirrection the entity should be facing and the current pan values, it then rotated the entity by this value so that as it get close to its mark is slows down forming a more natural action, however dispite trying this only lets the entity rotate one way and even worse sometimes it does multiple spins before reaching its target.

Any suggestions ot these problems?

Thanks!


For some reason, my ambition always seems to beat my ability.
Re: Drifting and Aiming problems [Re: sydan] #201536
04/09/08 19:32
04/09/08 19:32

M
Malice
Unregistered
Malice
Unregistered
M



 Code:
if(key_w)
{
my.force_x=1;
}
if(key_s)
{
my.force_x=-1;
}
if(!key_s && !key_w)
{
my.force_x=0;
}
my.relx+=my.force_x*(a_speed)*time_step; 
if(my.force_x ==0)
{
if(my.relx <0)
{
my.realx+=0.5*time_step;
}
if(my.relx >0)
{
my.realx-=0.5*time_step;
}
}



something like this is what I use for cars.. You can play with it.
Malice

Last edited by Malice; 04/09/08 19:34.
Re: Drifting and Aiming problems [Re: ] #201540
04/09/08 19:36
04/09/08 19:36
Joined: Oct 2007
Posts: 116
S
sydan Offline OP
Member
sydan  Offline OP
Member
S

Joined: Oct 2007
Posts: 116
And your cars don't keep on moving afterwards? Okay I'll try that. Thanks.
I wish I could help you with some of the problems ive seen you posting, but Im not really experience in those short of areas.


For some reason, my ambition always seems to beat my ability.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1