Yann's Recent Forum Activity

  • AArgh... You can't put that in properties. The property box will take all that you enter in it as a string, it won't parse any variable.

    You have to write that kind of stuff in event

    System: Every tick -> Text: set Text to "Score :"&Score
  • With the Physics behavior you have access to X and Y velocity, you just have to check if it's equal to 0. If it is, it means the sprite doesn't move.

    Also you might want to check if it's less than a small value. 'Cause it might take time to completely stop. Just test.

    Example:

    System: Sprite.Physics.VelocityX < 0.01
    System: Sprite.Physics.VelocityY < 0.01
       -> Sprite: set moving to false
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Depend if you use a behavior

    If you don't you might want to use a behavior

    If you can't just explain your situation a bit more

  • I'm working (well... I should be working) on my paid job.

    But as I'll use 8 direction and mouse in my c2 contest game I will probably have to find a solution.

  • Oh I see... Indeed really weird. It almost look like a focus issue.

    Like when you click the focus of the webpage is recalculated and in this time the arrow input are ignored... maybe...

  • zenox > it's an ergonomy problem then. But I don't think the "global" option should be disable. For one reason: it could be used effectively we just never encounter a case where it was.

    The more option the better, even if confusion can arise. People will ask, and learn some concept through design mistake.

  • There's not, you don't even want to use physics for that kind of stuff.

    If you have a start point and an end point you just want to calculate a curve.

    Physic is usefull if you want a movement to be the consequence of environnemental factor (gravity, wind, friction) Thus you can't really predict movement, and you don't really want to.

    The behavior you describe is really not physics driven.

    Indeed what squid showed is a curve calculation you can use the bullet behavior and tweak angle/speed during movement

  • How it was used in Mina's capx is not a proper use of global object. Global object shouldn't even be used for Graphical representation.

    The only things that should be global are data you want to keep through layouts (score/lives/position/etc)

    I used to use Global object in cc to avoid updating sprites in each layout each time I change things.

    But now Sprite instance even if not global share the same Object Definition in the Object library (Texture, variables, behavior, etc). So if you want to change animation or instance variable definition for the whole project, you can change on the instance and it will be changed for all layout even if it's not global.

    I can't really figure out why making graphical element global.

  • Please see this tutorial

    Cleaner

  • It really depends on your overall gameplay. There's no such thing as an univeral AI tutorial. Just some pointers and example. But you seem to have reach a state where you already have a working AI you just don't manage find the proper balance (that's what I understood reading you).

    So basically you should share your capx to have some input that fits your game. If you don't want to share all your work, try too replicate your basic mecanism in another capx and share it.

  • that's weird. I posted it 'cause I tested it with chrome and there wasn't any bug.

  • hmmm With your waypoint detector system (the orange sprites) you just have to compare laps and waypoint. But indeed you can't easily evaluate pixel by pixel when a car goes in front of another one. As in a race the space continuum is bent by the shape of the track.

    BUT that does not explain why you use different object for NPC.

    If you want different name, just use a variable with the name of the NPC

    If you want different speed parameter, you can tweak each instance

    If you want to count the number of lap or current waypoint for each NPC, just create an instance variable which will old the count for each.

    This way you can calculate position easily :

    NPC: X greater than FinishLine.X
    NPC: is overlapping FinishLine
       -> NPC: set backward to true
    NPC: X less than FinishLine.X
    NPC: is overlapping FinishLine
    NPC: [INVERT] is backward
       -> NPC: set crossing to true
    NPC: [INVERT] is overlapping FinishLine
        NPC: is crossing
           -> NPC: add 1 to lap
        Every tick
           -> NPC: set crossing to false
           -> NPC: set backward to false

    backward booleans are use to check if things goes in the right direction when you cross the finish line.

    For waypoint you will just have to check

    NPC is overlapping waypoint
       -> NPC: set trackPosition to waypoint ID

    Then you can calculate relative position with this formula:

    Every tick
        -> NPC: set racePosition to NPC.lap*waypoint.Count+NPC.trackPosition

    if your NPC crossed the line 3 times and is at the 5th waypoint and you have 20 waypoint, his position will be:

    3*20+5 = 65

    Then you just have to go through all your NPC to check position.

    Unfortunately we still don't have a foreach ordered by.

    So you will have to do a for loop between 0 and the max number of possible lap*number of waypoint.

    For instance if you have a race which last nbLap laps

    Global variable inc=1
    for 0 to nbLap*Waypoint.Count
        Local variable check=0
        NPC: racePosition equal loopindex
            -> NPC: set place to inc
            -> System: set check to 1
        Player: racePoistion equal loopindex
            -> Player: set place to inc
            -> System: set check to 1
        System: check equal 1
            -> System: add 1 to inc

    This assume you run the same kind of calculation for the player object.

    Which makes me think that you could also have the player object be the same as the other NPC but just deactivate NPCs by using a boolean you set in property panel.

    NPC: is Player
      -> activate the race behavior
      -> deactivate the bullet behavior
    NPC: [INVERT] is Player
      -> activate the bullet behavior
      -> deactivate the race behavior
      -> run the AI

    This way you can really have less event to maintain

    (Of course if there were families... You could just put NPC and Player into the same family and run all the above stuff just for the family)

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann