events: compile error for platformer character

I am trying to make an AI-controlled enemy and, to handle gravity, I have it have a platformer automatism. I then put into the events to simulate a right key press for the enemy. When it tries to compile the events, it generates compiler errors. What could be going wrong? I could link the project if you need it.

The reason I think it is a bug is because simulating key presses works just fine in my other project, a mini 2d minecraft clone.

You should send us the project. :wink:

Okay, here is a link to the project’s folder. There should be a download button at the top of the page to download as a zip.
drive.google.com/open?id=0B2f-m … authuser=0
I have traced down the problem a bit as well. My events list is now composed of two events:
-when mouse clicked, make object A pathfind to the mouse.
-simulate pressing right for object B
This causes a compile error. If I disable one of them, there are no compile errors and the other event works just fine. E.G. disabling path tracing allows the key press to work, and disabling the key pressing allows the pathfinding to work.

This is a bug in GDevelop indeed.
This may work as a workaround :

  • Put this file in “GDevelop Folder”\CppPlatform\Extensions\include\PathfindingAutomatism (and replace the one with the same name)
  • PathfindingAutomatism.h (4.47 KB)

Hm, the link results in an error for me. Could you maybe put it on pastebin or something similar?

Here is the full file :
[spoiler][code]/**

GDevelop - Pathfinding Automatism Extension
Copyright (c) 2010-2014 Florian Rival (Florian.Rival@gmail.com)
This project is released under the MIT License.
*/

#ifndef PATHFINDINGAUTOMATISM_H
#define PATHFINDINGAUTOMATISM_H
#include “GDCpp/Automatism.h”
#include “GDCpp/Object.h”
#include <SFML/System/Vector2.hpp>
#include
namespace gd { class Layout; }
class RuntimeScene;
class PlatformAutomatism;
class ScenePathfindingObstaclesManager;
namespace gd { class SerializerElement; }
class RuntimeScenePlatformData;

/**

  • \brief Compute path for objects avoiding obstacles
    /
    class GD_EXTENSION_API PathfindingAutomatism : public Automatism
    {
    public:
    PathfindingAutomatism();
    virtual ~PathfindingAutomatism() {};
    virtual Automatism
    Clone() const { return new PathfindingAutomatism(*this); }

    /**

    • \brief Compute and move on the path to the specified destination.
      */
      void MoveTo(RuntimeScene & scene, float x, float y);

    //Path information:
    /**

    • \brief Return true if the latest call to MoveTo succeeded.
      */
      bool PathFound() { return pathFound; }

    /**

    • \brief Return true if the object reached its destination
      */
      bool DestinationReached() { return reachedEnd; }

    float GetNodeX(unsigned int index) const;
    float GetNodeY(unsigned int index) const;
    unsigned int GetNextNodeIndex() const;
    unsigned int GetNodeCount() const { return path.size(); };
    float GetNextNodeX() const;
    float GetNextNodeY() const;
    float GetLastNodeX() const;
    float GetLastNodeY() const;
    float GetDestinationX() const;
    float GetDestinationY() const;

    //Configuration:
    bool DiagonalsAllowed() { return allowDiagonals; };
    float GetAcceleration() { return acceleration; };
    float GetMaxSpeed() { return maxSpeed; };
    float GetAngularMaxSpeed() { return angularMaxSpeed; };
    bool IsObjectRotated() { return rotateObject; }
    float GetAngleOffset() { return angleOffset; };
    unsigned int GetCellWidth() { return cellWidth; };
    unsigned int GetCellHeight() { return cellHeight; };
    float GetExtraBorder() { return extraBorder; };

    bool SetAllowDiagonals(bool allowDiagonals_) { allowDiagonals = allowDiagonals_; };
    float SetAcceleration(float acceleration_) { acceleration = acceleration_; };
    float SetMaxSpeed(float maxSpeed_) { maxSpeed = maxSpeed_; };
    float SetAngularMaxSpeed(float angularMaxSpeed_) { angularMaxSpeed = angularMaxSpeed_; };
    bool SetRotateObject(bool rotateObject_) { rotateObject = rotateObject_; };
    float SetAngleOffset(float angleOffset_) { angleOffset = angleOffset_; };
    unsigned int SetCellWidth(unsigned int cellWidth_) { cellWidth = cellWidth_; };
    unsigned int SetCellHeight(unsigned int cellHeight_) { cellHeight = cellHeight_; };
    float SetExtraBorder(float extraBorder_) { extraBorder = extraBorder_; };

    float GetSpeed() { return speed; };
    float SetSpeed(float speed_) { speed = speed_; };

    /**

    • \brief Unserialize the automatism
      */
      virtual void UnserializeFrom(const gd::SerializerElement & element);

    #if defined(GD_IDE_ONLY)
    /**

    • \brief Serialize the automatism
      */
      virtual void SerializeTo(gd::SerializerElement & element) const;

    virtual std::map<std::string, gd::PropertyDescriptor> GetProperties(gd::Project & project) const;
    virtual bool UpdateProperty(const std::string & name, const std::string & value, gd::Project & project);
    #endif

private:
virtual void DoStepPreEvents(RuntimeScene & scene);
virtual void DoStepPostEvents(RuntimeScene & scene);
void EnterSegment(unsigned int segmentNumber);

RuntimeScene * parentScene; ///< The scene the object belongs to.
ScenePathfindingObstaclesManager * sceneManager; ///< The platform objects manager associated to the scene.
std::vector<sf::Vector2f> path; ///< The computed path
bool pathFound;

//Automatism configuration:
bool allowDiagonals;
float acceleration;
float maxSpeed;
float angularMaxSpeed;
bool rotateObject; ///< If true, the object is rotated according to the current segment's angle.
float angleOffset; ///< Angle offset (added to the angle calculated with the segment)
unsigned int cellWidth;
unsigned int cellHeight;
float extraBorder;

//Attributes used for traveling on the path:
float speed;
float angularSpeed;
float timeOnSegment;
float totalSegmentTime;
unsigned int currentSegment;
bool reachedEnd;

};
#endif // PLATFORMEROBJECTAUTOMATISM_H

[/code][/spoiler]

Wait, nevermind. My hard drive was full. :blush:

Thank you, it worked perfectly :smiley:

it will be fixed “officially” in the next version of GDevelop.