Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jamesvhyde

Pages: 1 2
16
Ask a Question / Can you control the order of execution of behaviors?
« on: July 25, 2011, 05:53:16 pm »
I have an actor with four behaviors, each of which has a handler for collision. Is there a way I can control in what order the four handlers execute? One way to solve this would be to put all the collision code in one behavior, but I'd like to keep the behaviors as independent as possible.

17
Ask a Question / Re: Hyper-noob question: firing a MM-syle bullet
« on: July 25, 2011, 10:30:21 am »
One way to do it is the following:
  • Add a hidden attribute to your behavior called "Direction"
  • You have a movement behavior that makes the player actor move when the player hits some key, correct? In this behavior, you can add code to set the Direction attribute of the shooting behavior.
Take a look at the screenshot for an example.

Also, the Run and Gun Example Game has blocks to do exactly what you want, so you can take a look at that for ideas. It uses actor values to solve this particular problem, rather than attributes.

18
Ask a Question / Re: "Dead Weight" style actor bouncing
« on: July 20, 2011, 04:06:44 pm »
Well, do you think it's sliding, like I was talking about? Or is it actually bouncing? Try increasing the friction value (to 10 or something) of both actors and see if there's any change.

19
Ambvai, thanks for the the thoughts. It seems like what I want to do is not quite going to work, since you can't add more than one instance of the same behavior to a single actor. However, I think the solution that we've come up with is acceptable, so I'm marking this thread solved now.

I was able to improve the code a bit by combining the 4 directions of the sword into one actor with 4 animations. I didn't consider this at first because I didn't realize each animation could have its own collision shape. I wonder why the creators of the Action Adventure template created 4 separate actors for the sword.

20
Pilgrim, your code has a few problems:
  • Darkhog is correct: "Add x to list-x" and "Add y to list-y" have to be moved to directly below the "Create" block. If you add them before you check the list, of course the loop will always find them.
  • "If not false" is not the condition that you want. "not false" is always "true", so that block inside the "if" block will always execute.
  • You have two loops: "repeat 100 times" and "repeat number of items in list-x times". I'm guessing the "repeat 100 times" is there so 100 new actors are created. If that's the case, this loop has to go around everything in your code here; in other words "repeat 100 times" should be the first block inside "when created".
  • Finally, to get this to work, you are going to have to create a hidden boolean attribute to use with the "repeat number of items in list-x times" loop. This is what HNF was getting at. Call the attribute "found match". Set it to "false" just before the loop. Inside the "if" inside the loop (where you have "exit loop") set "found match" to "true". (I wouldn't put "exit loop" in there. I'm not sure which loop it's exiting.) Now, move the "if not false" block outside the "repeat number of items" loop. Finally, change the condition from "if not false" to "if not found match". This way, the "create" block will only execute if a match was not found in the loop.
Hope this helps. I think with 100 actors this code will not be too slow.

21
Ask a Question / Re: "Dead Weight" style actor bouncing
« on: July 19, 2011, 02:11:42 pm »
You can see this same problem in the "Run and Gun Example Game". Open the Bullet actor and deactivate the "Die upon Collision" behavior. The bullets seem to bounce off of the enemies, even though the bounciness values of both actors are set to 0. The bullets do not bounce off the walls, as expected.

After another look, I think the bullets are not bouncing off the (round) enemies, but sliding off. Even with friction set to 1 they do some sliding. What is the shape of your collision polygons?

22
The way that I solved this problem was to refactor the the original "Sword Attack" behavior into a "Weapon Attack" behavior for the player actor and a "Weapon Effect" behavior for the weapon actors.

The "Weapon Effect" controls where the new actor appears (it depends on the particular weapon actor animation), how long it stays on the screen, and the speed it moves across the screen.

The "Weapon Attack" controls movement of the player during the attack and creation of the weapon actor. It uses an if/otherwise block to determine which weapon actor to create, based on an "Equipped weapon" attribute.

This approach will make it easier to add new weapons, since they can use existing behaviors. However, I still say it defeats the purpose of attributes because it will require editing of the if/otherwise block in the "Weapon Attack" behavior. Ideally I want someone to be able to use my behaviors without editing the design.

Thanks for the responses. I don't feel I can mark this [solved] because I'm not entirely satisfied with the solution.

23
Thanks for the response. Using multiple interacting behaviors does seem to be the way to go. I will think about it and post again when I get a chance to try some things.

24
Thanks for the response. Duplicating the behavior is what I have been doing, but it is not an acceptable solution for the following reason: If I want to made a tweak to the design of the behavior, I have to do it in all of the duplicated behaviors as well, an approach that is tedious and error prone.

The if/elseif solution would be better, but it seems to defeat the purpose of having attributes to control the behavior. Some other ideas are beginning to come to me, but I will have to experiment.

Any other ideas, anyone?

25
It seems that I cannot add the same behavior multiple times to the same actor. I want to do this because the behavior behaves differently with different values for the parameters.

For example, in the Action Adventure template, the Sword Attack behavior can easily be modified for other weapons or spells simply be changing the attributes. An axe may have different behavior from a sword, but that can be controlled by behavior of the weapon actors. The actual attack from the player actor's point of view is the same. So I would like to add the Sword Attack behavior to the player actor twice.

Is there a good way to do this?

EDIT:
The answer to my original question, "Can you add the same behavior multiple times to one actor?" is no, at least not currently. See below for an acceptable solution to my problem.

Pages: 1 2