static actor animation follow another actor. help pls

Talk about making games.

static actor animation follow another actor. help pls

Postby Morpheas » Mon Feb 20, 2012 1:35 pm

hi there.
brand new member and beginner:P.

i have 2 actors in the backround and i want help with:
1)the cannon to be able to follow the croshair.i used this code that i found in some topic of this forum
in a draw actor event:animpos=(direction(x,y,croshair.x,croshair.y)/180)*nframes;
but the cannon looks the opposite way....
2)if u could tell me how to make the cannon stop rotation if u put the croshair under it.
edit to 2)1 option is to make a barrier with a colision event that the croshair cant pass it.
is there a way to tell it not to go under some coordenates.?

pls help a newbie :)
Attachments
test.exe
run the exe so u can have an idea of what i want
(1.85 MiB) Downloaded 91 times
Last edited by Morpheas on Thu Feb 23, 2012 5:04 pm, edited 2 times in total.
Morpheas
 
Posts: 17
Joined: Mon Feb 20, 2012 12:58 pm
Score: 1 Give a positive score

Re: static actor animation follow another actor. help pls

Postby skydereign » Tue Feb 21, 2012 7:05 am

I believe you mean that the code should be /360 instead of /180.
Code: Select all
animpos = (direction(x, y, crosshair.x, corsshair.y)/180) * nframes;

If that still doesn't work then make sure your animations starts facing right and rotates counter-clockwise.

As for your second question, essentially you only want to rotate when the crosshairs are a certain distance away. To do that you can use a function called distance (much like you did with direction).
Code: Select all
if(direction(x, y, crosshair.x, crosshair.y)>width) // you can change width to be whatever distance you want
{
    // put your animpos code here
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: static actor animation follow another actor. help pls

Postby Morpheas » Tue Feb 21, 2012 7:23 am

i just wake up i ll render my cannon again.does the rotation has to start to 90 degrees to the right exactly? could it be 80?and the motion corresponds well?
because to my spite doesn't look natural to rotate all the way to the sides.
i ll tell u what happens in a hour because i have some thing to do now:)
thx for the info
Morpheas
 
Posts: 17
Joined: Mon Feb 20, 2012 12:58 pm
Score: 1 Give a positive score

Re: static actor animation follow another actor. help pls

Postby skydereign » Tue Feb 21, 2012 9:23 am

Ah if that is the case you'll have to use a different equation. The proper one to use is dependent on two things, but the really important one being the animation itself. It is easiest if you animate the rotating sprite starting at 0 and rotate out from there (though it is possible to create it using several different ways).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: static actor animation follow another actor. help pls

Postby Morpheas » Tue Feb 21, 2012 10:03 am

can u tell me the collision code or something that will work with this files i send u
so the croshair doesn't go even 1 pixel beneath the borderline?
because whatever physical event or collision doesn't seems to work it bounces a little but it can still go even if i put repeat the event in collision.
until further notice the cannon0001.tga - cannon0300.tga is not to be used for commercial purposes.
if u want to use them send me a pm
Attachments
test.zip
(528.55 KiB) Downloaded 87 times
Morpheas
 
Posts: 17
Joined: Mon Feb 20, 2012 12:58 pm
Score: 1 Give a positive score

Re: static actor animation follow another actor. help pls

Postby skydereign » Tue Feb 21, 2012 8:54 pm

Well you can't use collisions since the border is very thin, but you can do something like this. There are other things that can be done to make this a little better, but since you are using the mouses position absolutely at some level you'll have to limit the crosshairs movement.
Attachments
test1.ged
(1.83 KiB) Downloaded 94 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: static actor animation follow another actor. help pls

Postby Morpheas » Wed Feb 22, 2012 10:02 am

i don't care about the thickness off the border.i thought it was better small but if u tell me that make it thicker will fix it then ok:)
i ll make it thicker and invisible:P
does the depth play a role in collisions?if u make a rule between 2 sprites?
thx again for all the help.
i saw after the test1.ged u gave me.nice trick.but it has some problems of its own i ll try some code to see whats better for my project.
ur code was this in a draw event in crosshair:

if(distance(cannon.xscreen, cannon.yscreen, xmouse, ymouse)>50 && view.y+ymouse<140)
{
xscreen=xmouse;
yscreen=ymouse;
}

i said the code so many more ppl can see it.
thx again for ur help.

edit:i tested some code and i was wondering if u could do something like this.
actor crosshair draw event collision all sides of borderline repeatable-->script editor: ymouse=-50;
but it doesn't have any effect.what i did wrong?:P
i think something like this will solve many problems.see the attachment.

1 more thing i have 2 actors with many images in animation and the first steals the animation of the second without me making it to do that.
i think it has to have something with the name of the images.is there an easy way to separate it by name?
i make my sprites in blender and it names the animations like ball10001.tga and the second actor has animations of ball1boom0001.tga.
i don't understand why this is happening is it because the starting word(ball) or the 0001...
Attachments
test.zip
(528.13 KiB) Downloaded 94 times
Morpheas
 
Posts: 17
Joined: Mon Feb 20, 2012 12:58 pm
Score: 1 Give a positive score

Re: static actor animation follow another actor. help pls

Postby skydereign » Thu Feb 23, 2012 1:49 am

xmouse and ymouse are read only variables. That means you can't actually change them. Your using a flat border makes things a lot easier. You don't need to use collisions (which would require a filled border as well as some odd positioning code). Instead you can just use this.
Code: Select all
xscreen = xmouse;
yscreen = min(ymouse, 345);

The 345 happens to be the value of ymouse when it is right above your border actor. Normally I'd use that actor's y variable and its height to determine the position above it, but since you didn't crop the borderline animation (it is 800x680 despite it being much smaller) it throws the positioning off.

The reason the animations are trampling each other is because of how gE does multiple frames. You should really just have each animation have a separate base name. In your case something like this.
ball_0000.tga
boom_0000.tga
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: static actor animation follow another actor. help pls

Postby Morpheas » Thu Feb 23, 2012 9:02 am

much better effect:) thx again
i was wandering is there some variable or function that will be able to effect the mouse?
i mean this does that thing in a way but it allows the mouse to continue down and it takes longer time for it to reach the border position which the crosshair stoped.
i think that there might be no way to freeze the mouse at some y.
m i wrong?

if u havent helped me i ll only had graphics :P
thx again
Morpheas
 
Posts: 17
Joined: Mon Feb 20, 2012 12:58 pm
Score: 1 Give a positive score

Re: static actor animation follow another actor. help pls

Postby skydereign » Thu Feb 23, 2012 9:07 pm

Currently gE can't change the mouse position. It's rather unfortunate but that's the way it is right now.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest