Rotating turret problem while parented...

Non-platform specific questions.

Rotating turret problem while parented...

Postby d-soldier » Mon Jun 18, 2007 5:39 pm

... So I've noticed a problem with parented actors... The image below shows my badguy ship actor, with four individual turrets parented to it. These turrets have a draw actor script of:

animpos = nframes*direction(x,y, player_target.x, player_target.y)/360.0;

This works fine for them to follow(point at) the pacman there, so long as they have no parent (the ship) ... Once they are parented, however, their tracking is completely off.... which is a problem because the bullets they shoot are angled at the pacman, though the barrels of the turrets are not pointed in the right direction...
Is there a way to script a bullet actor to be angled (on its create actor script) based on the animpos of it's creator??? or a fix for the parenting problem with tracking?
Attachments
roids6.jpg
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby d-soldier » Mon Jun 18, 2007 6:14 pm

I made a demo of the problem... just follow the directions, it's pretty obvious... Almost as if the turrets (once parented) track the pacman from where they (or their parent) started from, rather then where they are on a movement path... Still interested in how to script a bullet (actor) angle based on the animpos of it's creator though. :D
Attachments
turretbug.zip
(217.18 KiB) Downloaded 104 times
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby pixelpoop » Mon Jun 18, 2007 9:13 pm

I don't know why it is messing up like that but it looks like a bug.

a work around is:
I took out the touret clones and create them each as independent actors and had them inherit actions from the original touret. This way you only need to mess with code on one of the tourets.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby marathon332 » Mon Jun 18, 2007 9:46 pm

Put this on the draw actor event of the turret and remove the change parent action. Then the turrets will move properly...

xvelocity = a.xvelocity;

yvelocity = a.yvelocity;

Parenting the actors changes the way child actors behave (as you have seen).... too bad Makslane hasn't created a fix for this because your way of doing it is more natural...
User avatar
marathon332
 
Posts: 57
Joined: Tue Sep 06, 2005 4:00 am
Score: 2 Give a positive score

Postby d-soldier » Mon Jun 18, 2007 11:49 pm

Good fixes IF the ship was meant merely to move about the screen... however, given the ASTEROIDS style game this actor was developed for, it must be attatched to the "A" actor (the ship) so that when it exits the screen (left) they appear in the correct spots on it as it re-appears (right)... so it's a bug then?
Anyone know how to script a bullet's create actor regarding angle and velocuty based on the animpos of the creator? If I could do this then I could have the turrets spinning around and shooting randomly and not worry about this bug.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby marathon332 » Tue Jun 19, 2007 12:28 am

My solution worked for me in your demo... did you try it?

Unless I misunderstand you, it should work the way you want it to.

Are you destroying the actor?
User avatar
marathon332
 
Posts: 57
Joined: Tue Sep 06, 2005 4:00 am
Score: 2 Give a positive score

Postby d-soldier » Tue Jun 19, 2007 1:00 am

I assumed that the asteroids-draw actor scripting would be a problem, but as I think about it, you may be right... I'll try it tonight when I get home from work and let you know though! :D
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby pixelpoop » Tue Jun 19, 2007 9:39 am

I have used this code to control the bullets angle in a game of mine. Put it on the actor doing the creating.

Code: Select all
CreateActor("bul", "bul", "(none)", "(none)", 0, 0, false);
bul.angle=((animpos)*9);
//bul is my bullet actor
//9 times the total number of frames(40) of the creator actor is equal to 360.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby d-soldier » Tue Jun 19, 2007 2:55 pm

Ahh, I didn't mean the animpos of the bullet.. it's only got one sprite... sorry, I meant the angle/direction of it's movement... if the turret is at a 45 degree angle (lets say that animpos 8)when the timer goes off, can the bullet be scripted to shoot in a proper directions based on that?
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby d-soldier » Tue Jun 19, 2007 3:07 pm

Marathon, your solution works great until the ship goes off screen and re-appears on the opposite side (without the turrets) due to the scripting... So I may just need to re-work the entire level then, without the ship ever going off screen... regardless, +1 for you for a good solution!
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby pixelpoop » Tue Jun 19, 2007 3:56 pm

bullet.angle=turret.angle;
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby d-soldier » Tue Jun 19, 2007 10:10 pm

:shock: Theres no way its that simple... I'll check it once the 1.3.8 fix is released.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest