mattb's Recent Forum Activity

  • mattb

    The parameter of expression:ReflectionAngle is the normal vector. I only use the angle of the wall to be this input, so that it might be strange at the edge of wall, like your image 2 shown.

    So if I wanted to get correct reflections on all sides of a rectangular sprite, the way to do this would be:

    1. determine which side of the sprite is hit (by comparing the angle between sprite & hit point)

    2. for the 2 sides of the sprite with incorrect reflection, set the reflected angle of a Laser sprite to 'Laser.Light.ReflectionAngle(Sprite.Angle+90)'

    Is this right?

    (I've tried to set this up & I think my code for step 1 is faulty, but just wanted to confirm that I'm on the right track)

  • Another thank you for sharing this & all your other c2 addons.

    I just wanted to confirm something about this behavior- does ReflectionAngle only work for the sides of a sprite that are parallel to the sprite's angle?

  • That was it, thank you The text was just for debugging, & I thought destroying then creating it every 0.1s for <100 objects wouldn't make a dent in performance. I'll be more efficient with my debug text in future.

    So it's good to know that the pathfinding optimization works perfectly. I'll post an example file once I get a more complete system & hopefully help someone else out.

  • The pathfinding nodes get positioned to the nearest cell, so maybe what you could do is use your own movement system instead of pathfinding's in-built movement (eg. rexrainbow's MoveTo plugin), then have pathfinder create waypoints for each node. For the last waypoint, you'd ignore the final node & use mouse XY position (stored onButtonRelease when initially setting the path).

    There might be a way to do this with Pathfinding, but the only useful things I can see are the 'Is moving along path' condition & the 'CurrentNode' expression (NodeCount-1 would give you the final node), & no way of setting NodeX/Yat.

  • I'm trying to make a waypoint movement system where you double click to set the destination or append the current path. I found that the pathfinding behavior generates too many nodes for my purposes - I only want the bare minimum number of points but it sets extra ones around corners.

    So I fixed this with a hacky optimization where each waypoint has a line-of-sight behavior, & if it can see 2 nodes ahead then the following node is destroyed.

    This works & gives me a simplified set of waypoints. But, after 30-40 waypoints are made, there's some serious performance issues - cpu=100%, fps drops to around 40.

    I've attached a capx, maybe someone could take a look & see where I'm going wrong.

    Also if anyone has a better idea for generating a simplified set of waypoints then I'd love to know how.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Forgot to include the capx...

  • I got the idea for this from someone in the irc chatroom (I forget who) & it's a fun control system that I thought a C2 beginner might find useful to examine, or better yet an experienced user might expand upon & share their results.

    It works by making the player a spinning disc, with left & right move keys setting the angular velocity. A ground detector sprite determines when you can jump, detecting overlaps with a family of 'solids' (ie. immovable physics sprites).

    High linear damping & some additional downward force is the key to making the player physics settle down faster & feel more like the platformer behaviour.

    There's a basic platformer sprite in the scene for comparison (arrow key control for that, & WASD for the physics one), & you'll see the weak point of the physics player is the air control which I could never get to feel right. Maybe someone could have a go at some better code for that.

  • I'm trying to do a swinging elastic rope for a platform game, on a sprite with either physics or platform behavior, & drawn simply as a straight line - no segmented physics joints.

    The swinging will be used to perform jumps etc, so momentum is important. I don't want a perfect circular pendulum motion.

    I'm new to programming & terrible at maths, so could use some ideas about where to start with this (although I suspect it should be with a highschool maths or physics textbook). I've attached one of my failed attempts below, which gives a rough idea of the motion i'm after...

  • I'm using the FileReader plugin for loading back into the array, so file extension doesn't matter. I did try saving it as a json too, & that has the same hit & miss wierdness.

  • I'm making a very basic level editor, & its save function works by creating a temporary tester sprite which scans over the playing grid, & an array is then filled with values from objects that overlap the tester.

    The problem I'm having is that when downloading the array as a text file, it doesn't always save properly. Sometimes it downloads what looks like a random string of chinese characters, other times it works.

    The problem can usually be fixed in the level editor by pressing its reset button (clearing the array & playing grid of objects), then laying out again & saving.

    Any idea what might be causing this hit & miss behaviour?

    fyi here's what the save events look like:

    <img src="https://dl.dropboxusercontent.com/u/52354372/save_array_problem.png" border="0" />

  • I'm making a very simple level editor for a tile based puzzle game which can save & load text files to & from an array. The same thing would work with the Dictionary object too.

    To save, I use this action on the array:

    Download as JSON data with filename TextBox.Text & ".txt"

    (TextBox is the object I use to type in the filename for saving)

    Loading uses the FileReader plugin, which might not be ideal for your program since it uses an uncustomizable web button & can't be called with actions - you have to click on the button then browse to your text file. This is fine for a scrappy level editor though.

    So, the loading process is:

    FileReader > on file loaded > Array > load from JSON string FileReader.fileContent

  • ADenton - I think your first step before working out any event logic should be to clearly define states & behaviours for your guard, & think through every possibile situation for him.

    I would have the states (stored in the guard as a combination of bools or a single text variable) for a guard in a shooter game something like this:

    Patrol - walks between waypoints, relaxed posture; initial behaviour

    Patrol alert - walks between waypoints, combat pose; this behaviour triggered after being previously alerted, & could return to the initial patrol after a time.

    Suspicious - hears noise & stops patrolling; walks towards point of last noise; waits there for several seconds; if nothing found, walks to closest waypoint & state changes to 'patrol alert'

    Attack - has player line-of-sight, or saw player within eg. the last 10secs; runs at player & shoots; if player shoots back then run to nearest cover

    Alisa - yes I'm using MoveTo at the moment for some elevators, very handy behaviour

mattb's avatar

mattb

Member since 21 Nov, 2012

None one is following mattb yet!

Trophy Case

  • 12-Year Club
  • Email Verified

Progress

13/44
How to earn trophies