Page 1 of 1
Rotating turret problem while parented...
Posted:
Mon Jun 18, 2007 5:39 pm
by d-soldier
... 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?
Posted:
Mon Jun 18, 2007 6:14 pm
by d-soldier
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
Posted:
Mon Jun 18, 2007 9:13 pm
by pixelpoop
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.
Posted:
Mon Jun 18, 2007 9:46 pm
by marathon332
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...
Posted:
Mon Jun 18, 2007 11:49 pm
by d-soldier
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.
Posted:
Tue Jun 19, 2007 12:28 am
by marathon332
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?
Posted:
Tue Jun 19, 2007 1:00 am
by d-soldier
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!
Posted:
Tue Jun 19, 2007 9:39 am
by pixelpoop
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.
Posted:
Tue Jun 19, 2007 2:55 pm
by d-soldier
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?
Posted:
Tue Jun 19, 2007 3:07 pm
by d-soldier
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!
Posted:
Tue Jun 19, 2007 3:56 pm
by pixelpoop
bullet.angle=turret.angle;
Posted:
Tue Jun 19, 2007 10:10 pm
by d-soldier
Theres no way its that simple... I'll check it once the 1.3.8 fix is released.