Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/migueldeicaza/RealityActions
RealityActions
https://github.com/migueldeicaza/RealityActions
Last synced: about 1 month ago
JSON representation
RealityActions
- Host: GitHub
- URL: https://github.com/migueldeicaza/RealityActions
- Owner: migueldeicaza
- License: mit
- Created: 2023-08-04T17:12:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-07T00:26:03.000Z (about 1 year ago)
- Last Synced: 2024-10-29T22:52:45.117Z (about 1 month ago)
- Language: Swift
- Size: 57.6 KB
- Stars: 28
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-RealityKit - RealityActions - RealityActions brings the popular Cocos2D-style action framework to Entities in RealityKit. (Projects / Community)
README
RealityActions brings the popular [Cocos2D-style action
framework](https://docs.cocos2d-x.org/cocos2d-x/v3/en/actions/) to
Entities in RealityKit.Browse the [API Documentation](https://migueldeicaza.github.io/RealityActions/documentation/realityactions/).
To use, reference this module from SwiftPM:
```
https://github.com/migueldeicaza/RealityActions
```To use the framework, you must first register the Action framework
with RealityKit, at your program startup make sure you have something
like this:```swift
ActionManagerSystem.registerSystem()
```Then, you can execute one of the many available actions on your
entities, this is a snippet that moves an entity in a game:```
class SmallPlate: Weapon {
override var reloadDuration: Duration { .milliseconds(450) }
override var damage: Int { 10 }override func fire (byPlayer: Bool) async {
//let distance: Float = 10
guard let parent = await entity.parent else {
return
}@Sendable func fire (to: SIMD3) async {
let bullet = await createRigidBullet(byPlayer: byPlayer, size: size)
await bullet.addChild(smallPlateEntity.clone(recursive: true))await parent.addChild(bullet)
await bullet.run(MoveBy(duration: 3, delta: to))
await bullet.removeAllActions()
await bullet.removeFromParent()
}
await fire (to: [Float.random(in: -3...3), -2, 0])
}
}
```This one makes a small airplane rotate every 5 seconds:
```
airplane.start (RepeatForever (
DelayTime(duration: 5),
EaseBackOut(
RotateBy(duration: 1, deltaAngles: SIMD3 (0, 0, 360)))))```
# History
The action framework originated sometime with Cocos2D. Cocos2D
sprawled various different efforts, among those a port to .NET, which
lead to [CocosSharp](https://github.com/mono/CocosSharp), and later
this was ported to the 3D engine
[UrhoSharp](https://github.com/xamarin/urho).I ported the UrhoSharp codebase that added some 3D capabilities and
added various neat features using Async to Swift and RealityKit.