parenting makes angle fail

Non-platform specific questions.

parenting makes angle fail

Postby Novice » Fri Dec 02, 2005 5:28 pm

Ok, why does this happen?

When i parent an actor that has this code:
Code: Select all
int shooterangle;
shooterangle=direction(shooter.x,shooter.y,a.x,a.y);
animpos=shooterangle/22.5;

The animtion dosent follow the mouse like it should it shows some weird angles. BTW this works well when i unparent it.

I tried doing this
Code: Select all
shooter.x=car.x;

then the angle works good but the shooter lags behind the car 5 pixels wich looks really bad.

Please help! :cry:
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby makslane » Fri Dec 02, 2005 6:35 pm

Note: the x, y coordinates are relative to parent, so, if your shooter and a actors don't have the parent don't will works.

In this case, you must use xscren and yscreen that are the screen coordinates regardless the parent.

So, try use:

Code: Select all
shooterangle = direction(shooter.xscreen, shooter.yscreen, a.xscreen, a.yscreen);
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Novice » Sat Dec 03, 2005 10:07 am

Thanks it worked perfectly! :D

I have a simmilar problem with my tires.I have three of them and they have this
Code: Select all
//tire1
x=player.x+20;
//tire2
x=player.x;
//tire3
x=player.x-20;

The problem is that Tire 2 lags behind whenewer i move the player but Tires 1 and 3 work perfectly. I noticed that it lags by the amount i move the player
so if player is x+=5; Tire 3 will always be 5 pixels behind.
I hope i explaind it well. And again tanks for all your help.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby Novice » Sun Dec 04, 2005 10:22 am

Anyone?
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby makslane » Mon Dec 05, 2005 11:20 am

Are the tire 2 code in the Draw Actor event?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Novice » Mon Dec 05, 2005 11:58 am

Yes it is. I tried it now its not just in my curent game.I tried it out on a new game i creted two actors: actor A with key down events for x-=5; and x+=5;
and actor B with draw actor event x=A.x;
And the same thing hapens, it lags behind. As i understand when you say B.x=A.x that should be it, not B.x=A.x-5 or B.x=A.x+5.
I will send you a .ged file if you want.
Sorry for being such a bore but it is realy geting on my nerves.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby makslane » Mon Dec 05, 2005 12:51 pm

Please, send me this file.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Novice » Mon Dec 05, 2005 4:44 pm

I sent it
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby ericdg » Tue Dec 06, 2005 10:28 am

Can Novice or Makslane help me out.

I know I need to use animpos but I don't know how.

I used your script below

int shooterangle;
shooterangle=direction(shooter.x,shooter.y,a.x,a.y);
animpos=shooterangle/22.5;


But I don't know what anything means. I made 9 image files ranging from 40 degrees and one direction to 40 in the other. How do I put how many images it needs to use and how does it know where to start.

I have a car actor on top of two tire actors and when I drive it, the animation changes at all the wrong times.

Thanks guys, I'll get the hang of this yet.
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby ingsan » Tue Dec 06, 2005 1:25 pm

See these threads to know the difference between Animpos, Animindex & ActorCount 8)
http://www.game-editor.com/docs/script_ ... tm#animpos
http://www.game-editor.com/forum/viewto ... ht=animpos
User avatar
ingsan
 
Posts: 580
Joined: Mon Nov 17, 2003 4:02 pm
Location: Maurician LADY in FRANCE
Score: 6 Give a positive score

Postby Novice » Tue Dec 06, 2005 9:36 pm

If the links dont explain it let me know il try to help out.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby ericdg » Wed Dec 07, 2005 1:39 am

Yeah, I followed the links and I still can't figure it out. I just don't know what the 22.5 on your script is for, and how you can tell the script which image to put with which angle.

Novice, if you could just break down that script a little for me, I'd appreciate it.

I've got the basics of GE down, but I'm trying to learn the C scripting portion.

Thanks.
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby Novice » Wed Dec 07, 2005 10:52 am

Ok with int shooterangle you create a varibale that will hold the angle, you can use any name like int position or such.
With shooterangle=direction(shooter.x,shooter.y,a.x,a.y); you tell the computer that the angle is calculated using direction betwen two actors in this case shooter and a.
With animpos=shooterangle/22.5; you make animation change depending on the angle. I divide shooterangle with 22.5 because my animation has 16 frames so 360/22.5=16 for ex. if your animation is 360 degres rotation and has 10 frames you should divide the angle vith 36. 360/36=10 and so on.
If that dosent explain it fell free to ask again.

BTW i solved my lag problem, it is a bug that hapens when actor names begin with small letters so if you have the same problem just make the first letter capital ex. Player insted of player.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby ericdg » Wed Dec 07, 2005 2:37 pm

I'm finally starting to understand it.

If my animation has 8 frames, then does the 8 frames need to rotate all 360 degrees, or is there a way to limit it?

My animation has 8 frames but only rotates 40 degrees to the left and right since I don't need anymore rotation.

Do I need to make 24 more frames blank for the other rotation angles I won't use?

I tried a animation with 36 frames covering all 360 degrees and it worked great, but I would rather not have to make all those extra frames if not needed.


Also, what do you think would be the best way to slow a car down. When I press right arrow to speed up using xvelocity=xvelocity +.1; and I let go the car continues at this speed.

I could set a collision with the ground to slow down the car when I let off the right arrow using xvelocity=xvelocity -.1; but when it stops going right it starts going left.
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Postby ericdg » Wed Dec 07, 2005 3:20 pm

Also, is there a way to limit how far apart on the y axis the tires go. On the x axis they stay the same thanks to your tip on the bug Novice, but on the y axis they seperate by hundreds of pixels at times.
ericdg
 
Posts: 53
Joined: Tue Nov 29, 2005 1:18 pm
Score: 1 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron