![]() |
Car Movements Help
I am working on a "Car" for Graal Ghetto and so far all I have is the movement.
For my example I have added a block image to show the "Car". Although the movement is working perfectly the acceleration isn't. The problem is when accelerating if you turn it stops accelerating. Here is what I have so far. I am entrusting that the Graal community will NOT steal this, as I have spent about an hour and a half just getting this much. 2330 Characters long and 87 lines. Thanks. PHP Code:
Removed the players movement seeming as it isn't necessary. Also to make it harder for people to steal this script and actually use it. |
PHP Code:
PHP Code:
PHP Code:
And stop worrying about people stealing your scripts. It's not as big of a deal as you might think. |
Thanks, I wasn't aware of the if(keydown(0)){
I have always wondered if there was something like that. In flash it's if(key.is.down(KEY.UP)){ And regarding quotes, Im just use to using them. Il remember in future you dont need them. Would it be possible to have in a gani the showimg but have it something like this. PHP Code:
|
On an related note, is there any way to show an image and change its rotation serverside without using a gani?
Using a gani if you lag it looks retarded. |
use a weapon and a showimg statement with an index less the 200, while setting the player gani to only show the head. Should work relatively well :)
and I did something like this a while back so I'll show a player direction formula with you that I nutted out while falling asleep in my maths lecture: (int((angle+(pi*.25))/(pi*.5))+3)%4 That should work logic wise, no guarantees it'll definately work though |
Thanks, but I can't seem to get the rotation of the image to show serverside without putting it in a gani.
And putting it in a gani makes it laggy. As for your equation thanks, it helps. I never paid attention during any math lectures.. As I can understand it, its something like this. Integer of the angle plus 3.14 times by 0.25 divided by 3.14 times by 0.5 + 3 % 4. Im unsure of the %4 though. I mean it's going to be percentage 4, but how does that make sense? Maybe it's just the GS2 syntax of how that's set out that I don't understand.. |
Quote:
|
Thanks..
But as I have said, is there any way of getting the images rotation to either show as a gani (SMOOTHLY) even when lagging, or make the findimg(index).rotation = this.angle serverside? I have tried it in a gani but with the slightest lag it makes it jumpy. |
Quote:
|
I was doing something like this.
In the main script every 0.05 second on a timeout I was making player.attr[4] the car image and player.attr[5] the angle. then in the gani every 0.05 seconds I was updating the images angle. something like this. PHP Code:
|
This might help you
http://forums.graalonline.com/forums...highlight=gani |
Quote:
PHP Code:
|
What kind of lag are you seeing with your solution? It looks like it ought to work fine as long as you're putting it in a player attribute, not using it as the player's GANI.
|
When you turn left the angle is in the minus and it just gets jumpy and goes from say 36° to around 46° and it looks really bad.
I think I may have found a fix. I have made the start angle extremely high, in the millions so that the player would have to turn left about 20,000 times to undo it. |
Quote:
If it's the latter, then there's not much you can do about it besides inter/extrapolation which is overkill at this point. Post the code of how you're setting the GANI in the car script. |
Never mind, it seems to be working on.
it was a problem when turning left with the angle going minus that was stuffing it. I just set the start angle and it works fine now. Now all I need to do is the characters head and im done. |
I now have the cars rotation, player head rotation and now reversing.
Any idea's one how I could make something so if it hit a wall it would bounce back? Well I know the bounce back bit. In my script I have on a timeout if the speed is less than zero that it will slowly stop.. But how would the wall checks work for something like this? the most complex part I know is if(onwall(x, y)){ Pretty sad eh? To clarify it up for anyone that doesn't understand. I am wondering how I could make something caculate if there is a wall I front of you and bounce you back. How would you get all the on wall checks to work ^_~ |
Use the same math you're using to move the car to check if that x, y position is on a wall. If it is then 'bounce back'.
|
You can invert the angle easily by doing
invertedangle=(angle+pi)%(pi*2) as for the power, I would subtract a little from the initial collision. Then use the same direction formula you have already been given. |
Thanks for the help, il get started on the collision checking when I get home.
|
Quote:
|
Quote:
|
I know how to detect if there on a wall, but how would I handle it?
I have tried reversing the players movement which is this. PHP Code:
I think I'm in way over my head. |
Quote:
|
Quote:
Quote:
Also for those who don't know % is the mod operator. It works by spitting out the remainder of 2 given numbers. Eg:6%4=2, 6%5=1, 11%10=1 |
Update: I now have collision detection and it works.
Next up: When you fire the weapon it should put you in the car, when you press A it should place a NPC of the car on the map and allow you to press A next to it to enter. @Everyone Thanks for all your help |
All times are GMT +2. The time now is 11:05 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.