Jump to content


Photo

Help example truck_game


  • Please log in to reply
25 replies to this topic

#1 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 24 April 2012 - 04:17 PM

Hello friends.
I recall once again that I am still learning.
I ask once again for your help. (very nice existence of this community)

I downloaded from the internet and I'm truck_game example by changing the codes to learn from it.
Insert here the sequence is too long.
Download example here: http://game-maker.ru...ad.php?did=1575

W = forward
S = behind
A = Left
D = right
C = camera

My problem:
Note when the vehicle starts to move, the wheels moving for a short time in the opposite direction of the march.
I would like to eliminate this effect.
I wish to obtain the wheels always aligned with the vehicle.
I changed almost every code to figure out where I had to intervene, but alone can not.
Someone please help me.


I apologize for failing to meet 48 hours.
I apologize for just about correct.
I use Game Maker 8.
The example works well, the wheels of the vehicle moving in together but remain little moved.
Now example and press C to start 4 times, you should get bigger view of the vehicle and almost sideways.
Choose a path free from obstacles.
Now press W, to pay attention to the wheels and suspensions that are moved during running than when they were quivers.
I would like to eliminate this effect.
While driving, I would like that the wheels remain in the same position as when they were still.

Edited by lollolc, 25 April 2012 - 04:56 AM.

  • 0

#2 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 24 April 2012 - 06:46 PM

Help?
  • 0

#3 eafg2

eafg2

    GMC Member

  • GMC Member
  • 166 posts

Posted 24 April 2012 - 06:52 PM

You shall not bump within 48 hours!
Anyway it worked for me, more information would be nice.
What GM version are you using.
What have you change from the original code ect.
  • 0

#4 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 24 April 2012 - 06:58 PM

I dowloaded the game and cannot replicate the issue. As soon as I start moving forward, the wheels move forward. Can you try the program on another computer?

By the way, there's a 2-day bump rule on posts. Just an FYI.
  • 0

#5 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 25 April 2012 - 05:19 AM

I edited my first message.
Now I hope it's more understandable.
If the message still does not understand even try to explain ok?
Hello friends
Thanks and I hope for your help.
  • 0

#6 ParodyKnaveBob

ParodyKnaveBob

    theUndiscovered

  • GMC Member
  • 1350 posts
  • Version:GM:Studio

Posted 25 April 2012 - 05:28 AM

Howdy, lollolc,

Perhaps it would help if you did this:

1. Show the original example's code segments for wheels turning.

2. (Most important!) Show what changes you made to those segments. (Show your new code segments for wheels turning.)

Regards, $:^ )
  • 0

#7 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 26 April 2012 - 04:42 PM

I'm sorry, I just can not change where to get what I want.
Please could you tell me what should I change to get what I want?
Insert segments of code that should concern only the wheels.

Create events:
obj_camera.mode=1;
direction=180;
speed=0;
rx=0 ry=0 lx=0 ly=0
t1x=0 t1b=5 t1s=0
t1y=0
t1z=5
t2x=0 t2b=5 t2s=0
t2y=0
t2z=5
t3x=0 t3b=5 t3s=0
t3y=0
t3z=5
t4x=0 t4b=5 t4s=0
t4y=0
t4z=5
t1zmin=0
t2zmin=0
t3zmin=0
t4zmin=0
t1zspd=0
t2zspd=0
t3zspd=0
t4zspd=0
turn=0
y_rot=0
x_rot=0
tirerot=0
t1jump=0
t2jump=0
t3jump=0
t4jump=0
spdmod=0
t1spdmod=0
t2spdmod=0
t3spdmod=0
t4spdmod=0
t1a=0
t2a=0
t3a=0
t4a=0
z=5
rim=0
ttt=background_get_texture(bac_tire);
tt2=background_get_texture(bac_tire2);
tt3=background_get_texture(bac_rim1);
tt4=sprite_get_texture(bac_rim2,rim);
tt5=background_get_texture(bac_spring);
col=make_color_rgb(obj_red.x-90,obj_green.x-90,obj_blue.x-90);
aaa=background_get_texture(bac_car2);
ooo=background_get_texture(bac_oldmet);
tire=d3d_model_create()
d3d_model_cylinder(tire,-5,-5,-2,5,5,2,1,1,false,16);
tire1=d3d_model_create()
d3d_model_floor(tire1,-5,-5,2,5,5,2,1,1);
d3d_model_floor(tire1,-5,-5,-2,5,5,-2,1,1);
tire2=d3d_model_create()
d3d_model_cylinder(tire2,-3,-3,-1.97,3,3,1.97,1,1,false,16);
tire3=d3d_model_create()
d3d_model_floor(tire3,-3,-3,1,3,3,1,1,1);
d3d_model_floor(tire3,-3,-3,-1,3,3,-1,1,1);

Step events:
// основной L && R положения
lx=x+lengthdir_x(6,direction+90)
ly=y+lengthdir_y(6,direction+90)
rx=x+lengthdir_x(6,direction+270)
ry=y+lengthdir_y(6,direction+270)
//положения шины
t1x=rx+lengthdir_x(9,direction);
t1y=ry+lengthdir_y(9,direction);

t2x=lx+lengthdir_x(7,direction+180);
t2y=ly+lengthdir_y(7,direction+180);

t3x=lx+lengthdir_x(9,direction);
t3y=ly+lengthdir_y(9,direction);

t4x=rx+lengthdir_x(7,direction+180);
t4y=ry+lengthdir_y(7,direction+180);

if t1z<t1zmin && t1z>(t1zmin-3)
{t1z=t1zmin;t1zspd=0;t1jump=0;}
if t2z<t2zmin && t2z>(t2zmin-3)
{t2z=t2zmin;t2zspd=0;t2jump=0;}
if t3z<t3zmin && t3z>(t3zmin-3)
{t3z=t3zmin;t3zspd=0;t3jump=0;}
if t4z<t4zmin && t4z>(t4zmin-3)
{t4z=t4zmin;t4zspd=0;t4jump=0;}

if t1z<t1zmin-3
{t1spdmod+=.5;}
else
{t1spdmod=0;}
if t2z<t2zmin-3
{t2spdmod+=.5;}
else
{t2spdmod=0;}
if t3z<t3zmin-3
{t3spdmod+=.5;}
else
{t3spdmod=0;}
if t4z<t4zmin-3
{t4spdmod+=.5;}
else
{t4spdmod=0;}

t1zmin=5;
t2zmin=5;
t3zmin=5;
t4zmin=5;

t1z-=t1zspd;
if t1z>t1zmin
{t1zspd+=.8;}

t2z-=t2zspd;
if t2z>t2zmin
{t2zspd+=.7;}

t3z-=t3zspd;
if t3z>t3zmin
{t3zspd+=.8;}

t4z-=t4zspd;
if t4z>t4zmin
{t4zspd+=.7;}

z=(((t1b+t3b)/2)+((t4b+t2b)/2))/2;
y_rot=((t1b+t3b)/2-(t4b+t2b)/2)*4.2;
x_rot=((t1b+t2b)/2-(t3b+t4b)/2)*4.2;
if t1z<5
{t1z=5;}
if t2z<5
{t2z=5;}
if t3z<5
{t3z=5;}
if t4z<5
{t4z=5;}
t1a=0;
t2a=0;
t3a=0;
t4a=0;

{
if keyboard_check(ord("W")) && speed<1.3 && spdmod=0 {speed+=.015;}
if keyboard_check(ord("S")) && speed>-.8 && spdmod=0 {speed-=.015;}

if keyboard_check(ord("W")) && t1spdmod>1 {t1zspd-=.02;}
if keyboard_check(ord("S")) && t1spdmod>1 {t1zspd-=.02;}

if keyboard_check(ord("W")) && t2spdmod>1 {t2zspd-=.02;}
if keyboard_check(ord("S")) && t2spdmod>1 {t2zspd-=.02;}

if keyboard_check(ord("W")) && t3spdmod>1 {t3zspd-=.02;}
if keyboard_check(ord("S")) && t3spdmod>1 {t3zspd-=.02;}

if keyboard_check(ord("W")) && t4spdmod>1 {t4zspd-=.02;}
if keyboard_check(ord("S")) && t4spdmod>1 {t4zspd-=.02;}

if keyboard_check(ord("A")) && turn<1 && (t1z<t1zmin+.5 || t3z<t3zmin+.5){turn+=.041;}
if keyboard_check(ord("D")) && turn>-1 && (t1z<t1zmin+.5 || t3z<t3zmin+.5){turn-=.041;}
if speed>0
{speed-=.006}
if speed<0
{speed+=.006}
direction+=turn*2*speed;
if turn>0
{turn-=.02}
if turn<0
{turn+=.02}
tirerot-=speed*10;
if tirerot>360
{tirerot=0;}
if obj_camera.mode=0
{speed=0;
direction+=.5}
}

Draw events:
{
texture_set_interpolation(0)
d3d_transform_set_identity()
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_y(tirerot);
d3d_transform_add_rotation_z(direction+turn*20);
d3d_transform_add_translation(t1x,t1y,t1z);
d3d_model_draw(tire,0,0,0,ttt);
d3d_model_draw(tire1,0,0,0,tt2);
d3d_model_draw(tire2,0,0,0,tt3);
d3d_model_draw(tire3,0,0,0,tt4);
d3d_transform_set_identity()
d3d_transform_set_identity()
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_y(tirerot);
d3d_transform_add_rotation_z(direction+turn*20);
d3d_transform_add_translation(t3x,t3y,t3z);
d3d_model_draw(tire,0,0,0,ttt);
d3d_model_draw(tire1,0,0,0,tt2);
d3d_model_draw(tire2,0,0,0,tt3);
d3d_model_draw(tire3,0,0,0,tt4);
d3d_transform_set_identity()
texture_set_interpolation(1)

texture_set_interpolation(0)
d3d_transform_set_identity()
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_y(tirerot);
d3d_transform_add_rotation_z(direction);
d3d_transform_add_translation(t2x,t2y,t2z);
d3d_model_draw(tire,0,0,0,ttt);
d3d_model_draw(tire1,0,0,0,tt2);
d3d_model_draw(tire2,0,0,0,tt3);
d3d_model_draw(tire3,0,0,0,tt4);
d3d_transform_set_identity()
d3d_transform_set_identity()
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_y(tirerot);
d3d_transform_add_rotation_z(direction);
d3d_transform_add_translation(t4x,t4y,t4z);
d3d_model_draw(tire,0,0,0,ttt);
d3d_model_draw(tire1,0,0,0,tt2);
d3d_model_draw(tire2,0,0,0,tt3);
d3d_model_draw(tire3,0,0,0,tt4);
d3d_transform_set_identity()
texture_set_interpolation(1)
}

Help?
  • 0

#8 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 27 April 2012 - 04:40 PM

I'm sorry, I just can not change where to get what I want.
Please could you tell me what should I change to get what I want?
Insert segments of code that should concern only the wheels.

Help?


Wish I could, but I cannot replicate the problem you are having, and therefore cannot fix something that isn't broken. Have you tried this on another computer? Also, do you have GM 8 or 8.1? You may want to update to 8.1 if you haven't done so...
  • 0

#9 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 28 April 2012 - 07:11 AM

I repeat that all work properly and there is no error.
I only want to delete an effect I do not like.
I use GM8.
I also own GM8.1.
I ran in GM8.1 example and there are no errors, so if you want you can help me with GM8.1.

I'll try to explain again what to wish for.
Look at this picture: http://imageshack.us...151/veicle.jpg/
Vehicle is stationary at the top.
Vehicle is moving down. (the wheels are moved than when the vehicle was stopped)

My desire is to get that when the vehicle is in motion the wheels remain in the same position as when they were still.
  • 0

#10 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 30 April 2012 - 04:26 AM

Help?
  • 0

#11 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 30 April 2012 - 05:53 AM

While driving, I would like that the wheels remain in the same position as when they were still.

Just so we understand what you want: When the vehicle moves forward or backwards, you do NOT want the wheels to spin at all. Is this correct?
It would be as if you were driving along then hit a giant patch of ice. If you slammed on the brakes, the wheels would stop moving, but the car would keep its momentum. Is this an accurate interpretation of what you are trying to accomplish?

If so, simply comment out the four d3d_transform_add_rotation_y(tirerot) functions in the DRAW event of object 'car'. Once you do that, you can skate around all day long and your wheels will never move.
  • 0

#12 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 01 May 2012 - 04:48 AM

This is not what I want.
I want wheels turn.
I thank you all for your generous help.
Last time I try to explain my situation.

If vehicle is running, wheels remain behind in a few millimeters.
I want wheels do not stay behind.
  • 0

#13 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 01 May 2012 - 05:01 AM

This is not what I want.
I want wheels turn.
I thank you all for your generous help.
Last time I try to explain my situation.

If vehicle is running, wheels remain behind in a few millimeters.
I want wheels do not stay behind.

Ha ha! This miscommunication is almost comical. I'm not laughing at you. I'm laughing because what you are asking for, in my native English, is exactly what I have provided. However, I understand that you may be finding it a challenge to use the right words to explain your needs, so I shall once again attempt to interpret.

I've run the game again to see what's being "left behind". I saw that the entire frame of the truck (including the wheels) does lag a bit due to what appears to be an effect of the physics engine. In other words, you press W, the body of the truck moves forward, and the frame with wheels moves slightly later than the body. You can really see the effect when you slow the speed of the room down.

Is that what you are referring to? Or is it literally how the wheels are spinning that you want changed?
  • 0

#14 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 01 May 2012 - 05:44 AM

It is this!
How can I change?

I apologize for my English
  • 0

#15 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 01 May 2012 - 05:52 AM

It is this!
How can I change?

I apologize for my English

It's OK! ; ) Glad we were able to finally come to the point.

This code has no comments, and no understandable variable names, making it extremely challenging to sift through.

I think I've narrowed down the area to look at. I'm still playing with it, but perhaps you could try changing some things too.
Look in the 'car' object, the 2nd "Execute a piece of code" component under the STEP event. In there, if you comment out the entire code, then run the game, you'll notice the effect you are talking about disappears. The wheels are gone too, but that's not the point. Somewhere in that code is the solution.

To comment out the code, put /* at the very beginning, and */ at the very end. This should make the entire script green, if you have your colors set like mine are. Run the game, then go back and remove the /* and */, then start playing with the numbers, or commenting out other parts of this code.
  • 0

#16 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 01 May 2012 - 10:16 PM

I've spent a lot of time commenting out pieces of code, but have gotten nowhere. I don't know enough about the 3D physics it's using, but especially, without any code comments, I can't tell a t1z from a b1x. In other words, I cannot locate where exactly in code the body of the vehicle moves forward while the frame and wheels are a tad behind.

It's really the opposite of what should happen actually. In the real world, the torque would be at the wheels, causing the springy body to lurch back as the frame moves forward. But, with this, the body of the truck moves forward first, then the frame follows after. Weird. It's just a piece of code somewhere that needs adjusting, but for the life of me, I cannot find it. I've spent too much time looking, so I'm passing the baton to someone else.

My advice is to perhaps send a message to someone in the 3D forums. Someone who's actually made a 3D driving game perhaps. The answer is likely simple, I just don't have it. Maybe someone will read this and reveal the obvious.

Best of luck!

PS: If you're new to GM and you're using this truck code as an example to help you learn, I will pray for you.
  • 0

#17 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 02 May 2012 - 08:42 AM

Yes, I'm new.
Yes I use this example to learn.
I groped to contact Russian guy who created this example.
Thanks for your help
  • 0

#18 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 02 May 2012 - 07:11 PM

Yes, I'm new.
Yes I use this example to learn.
I groped to contact Russian guy who created this example.
Thanks for your help

I think if you asked in the 3D forum, you might have more luck. Since no one seems to have a solution for you in this forum.
  • 0

#19 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4238 posts
  • Version:GM:Studio

Posted 03 May 2012 - 02:39 PM

Object car, draw event, first action, replace both:
d3d_transform_add_rotation_z(direction+turn*20);
with
d3d_transform_add_rotation_z(direction);

Guys, really ?
  • 0

#20 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 03 May 2012 - 04:36 PM

Object car, draw event, first action, replace both:

d3d_transform_add_rotation_z(direction+turn*20);
with
d3d_transform_add_rotation_z(direction);

Guys, really ?

It would be great if you could share exactly what change this code is suppose to change about the truck movement. After altering the code, I don't see that it prevents the body of the truck from moving ahead of the frame and wheels. Unless there's something I'm not seeing. Looking forward to your reply.

Edited by integrate, 03 May 2012 - 04:37 PM.

  • 0

#21 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4238 posts
  • Version:GM:Studio

Posted 03 May 2012 - 04:54 PM


Object car, draw event, first action, replace both:

d3d_transform_add_rotation_z(direction+turn*20);
with
d3d_transform_add_rotation_z(direction);

Guys, really ?

It would be great if you could share exactly what change this code is suppose to change about the truck movement. After altering the code, I don't see that it prevents the body of the truck from moving ahead of the frame and wheels. Unless there's something I'm not seeing. Looking forward to your reply.

It prevents the wheels from turning to misalignment relative to the vehicle.

If it's the translational misalignment what he's concerned about, then changing the car step event into end step will fix it (this way the tire coordinates will be aligned according to the freshest value of direction).
  • 0

#22 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 03 May 2012 - 05:04 PM



Object car, draw event, first action, replace both:

d3d_transform_add_rotation_z(direction+turn*20);
with
d3d_transform_add_rotation_z(direction);

Guys, really ?

It would be great if you could share exactly what change this code is suppose to change about the truck movement. After altering the code, I don't see that it prevents the body of the truck from moving ahead of the frame and wheels. Unless there's something I'm not seeing. Looking forward to your reply.

It prevents the wheels from turning to misalignment relative to the vehicle.

If it's the translational misalignment what he's concerned about, then changing the car step event into end step will fix it (this way the tire coordinates will be aligned according to the freshest value of direction).

That makes sense. I just changed the STEP event as you mentioned, and it removed the misalignment. The body now rides solidly on top of the frame. Very astute Tepi.

I guess we'll wait to hear from our Russian friend to find out if your contribution meets his criteria. Thanks!
  • 0

#23 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 03 May 2012 - 09:50 PM

Object car, draw event, first action, replace both:

d3d_transform_add_rotation_z(direction+turn*20);
with
d3d_transform_add_rotation_z(direction);

Guys, really ?


In this way the front wheels do not steer.
The problem remains.
The problem is:
The vehicle begins to run and the body of the vehicle remains in front of the frame and wheels.
  • 0

#24 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4238 posts
  • Version:GM:Studio

Posted 04 May 2012 - 09:00 AM

Read the next post I sent.
  • 0

#25 lollolc

lollolc

    GMC Member

  • GMC Member
  • 112 posts
  • Version:GM8

Posted 04 May 2012 - 02:28 PM

I'm Italian
It works!
I feel stupid.
The solution was before my eyes. Sometimes I should stop Game Maker for a few days and then again groped.

Thanks to all!
Grazie a tutti!
  • 0

#26 integrate

integrate

    GMC Member

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 04 May 2012 - 06:27 PM

I'm Italian

Oops! Mi scusi!
Glad it's working for you now. I knew one of the brainiacs in this group would have the short, simple answer. : D
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users