Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 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 | chip programmers | 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