09 ConstrainingPlayerMovement - project-SIMPLE/simple.toolchain GitHub Wiki
Link to the example model: LinkToUnity/Models/Code Examples/Limit Player Movement.gaml
There are 3 ways to constraint the movement of a player from GAMA:
- Enable/disable the movement of the player
- Build invisible walls around a given set of geometries
- Define a specific geometry for the teleportation area
To enable/disable the movement of the player, use the « enable_player_movement » action of the Unity Linker.
do enable_player_movement(
player:the_player, //player agent concerned
enable:enable_movement //true (enable movement) or false (disable movement)
);
To build invisible walls around a given set of geometries, use the « build_invisible_walls » action of the Unity Linker.
//build invisible walls surrounding the free_area geometry
do build_invisible_walls(
player: last(unity_player), //player to send the information to
id: "wall_for_free_area", //id of the walls
height: 40.0, //height of the walls
wall_width: 1.0, //width of the walls
geoms: [free_area] //geometries used to defined the walls - the walls will be generated from the contour of these geometries
);
To define a specific geometry for the teleportation area, use of the « send_teleport_area » action of the Unity Linker.
// change the area on which the player can teleport
do send_teleport_area(
player: last(unity_player), //player to send the information to
id: "Teleport_free_area",//id of the teleportation area
geoms: [free_area] //geometries used to defined the teleportation area
);