Results 1 to 3 of 3

Thread: Interaction between two entities - Grabbing

  1. #1
    Peasant
    Join Date
    Mar 2008
    Posts
    9

    Default Interaction between two entities - Grabbing

    Hi,

    I'm trying to make a mod of the RPG example in Novashell and I'm having a hard time getting two entities to interact with each other.

    Basically, I want to be able to have one entity (the player) be able to approach another entity and initiate an animation at the press of a button. I'm trying to get it so I can have the player grab enemies, hold onto them, and then throw them by using the Alt key. How is it possible to attach two entities together like that and still have them perform animations that I create? I've already created the animations and can get them to work in the game using the force animation state, but I can't get beyond that.

    I'm new to scripting and programming so I could use the help as I'm more of the artist/designer type.
    Last edited by Siris; 03-20-2008 at 09:41 AM. Reason: revision

  2. #2
    Squire
    Join Date
    Jan 2008
    Posts
    19

    Default

    I tried to do something similar with an object that was supposed to constantly be under the player.
    What I tried was to update this entitys position in the players Update(step) function like this:
    Entity:RunFunction("SyncPosWithPlayer()")
    And SyncPosWithPlayer() would then be a function in the entitys script which changed it's position to the players.
    This didn't work because it lagged a bit and then I changed my mind on how I wanted it to work.
    After that I did find a function in the API called SetAttach which seems to do what you want. You can check it out here:
    http://www.rtsoft.com/novashell/docs...tity.SetAttach
    I haven't tried it myself but if you use it in the entitys script with the players ID it should work.

    As for the animation I also did some things with force animation state, but it was too difficult to get it to go back to the original animation after the one in force state had finished.
    This is what I think one should do:
    In the entitys visual profile XML file you need to add a profile for every state the entity can be in(normal, being held e.t.c.) like this:
    <resources>

    <profile name="standard">

    <anim state="idle_left" spritename="idle" x="0" y="0"/>

    <anim state="walk_left" spritename="walk" x="0" y="0"/>

    <anim state="attack_left" spritename="attack" x="0" y="0"/>

    <anim state="die_left" spritename="die" x="0" y="0"/>

    </profile>

    <profile name="held">

    <anim state="idle_left" spritename="idle_held" x="0" y="0"/>

    <anim state="walk_left" spritename="walk" x="0" y="0"/>

    <anim state="attack_left" spritename="attack" x="0" y="0"/>

    <anim state="die_left" spritename="die" x="0" y="0"/>


    </profile>

    <sprite name="idle">
    <image fileseq="art/idle_.png" leading_zeroes="1"/>
    <translation origin="center"/>
    <animation pingpong="yes" loop="yes" speed="150"/>
    </sprite>

    <sprite name="idle_held">
    <image fileseq="art/idle_held_.png" leading_zeroes="1"/>
    <translation origin="center"/>
    <animation pingpong="yes" loop="yes" speed="150"/>
    </sprite>

    ...Other sprite info....

    </resources>
    As you can see we have two profiles and the only difference between them is which sprite name is called for the idle_left state.

    If we call this file entity.xml then in the entitys script you would put:
    this:SetVisualProfile("~/entity.xml", "standard");
    In it's OnInit function to set all the animations for when nothing is happening and when the player grabs it you call:
    this:SetVisualProfile("~/entity.xml", "held");
    Which will change it's idle_left animation to a different one.

    This is of course assuming that the entity would be in the idle_left state. You could change whatever state you want.

    Unfortunately I haven't tried this either since I'm trying to learn how to use photoshop at the moment. It's the simplest solution I could figure out, but maybe Seth knows a better way?

  3. #3
    Peasant
    Join Date
    Mar 2008
    Posts
    9

    Default Thanks

    I tried getting it to work using SetAttach in the enemy's script, and while it would attach the two sprites together it kept having problems. Every time to two sprites attached together they would start sliding diagonally downwards.

    So I did manage to get both entities to play their proper animations, but I couldn't get them to interact with each other the way I wanted. I started modding the platformer adventure game instead and I'm learning quite a bit, so I can go without knowing how to fix that for a while.

    If I manage to get it working I'll post the solution up on the boards and in the examples thread.
    Last edited by Siris; 03-22-2008 at 05:19 AM. Reason: addition

Similar Threads

  1. Getting Entities to discover the Brain State of other entities
    By stellarvector in forum Novashell Game Creation System
    Replies: 1
    Last Post: 06-28-2007, 11:11 PM
  2. Rotating tiles/entities
    By sphair in forum Novashell Game Creation System
    Replies: 0
    Last Post: 03-12-2007, 09:33 PM
  3. Skill Based Customer Interaction?
    By redink1 in forum Funeral Quest
    Replies: 10
    Last Post: 12-23-2002, 09:52 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •