Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Victor Bjelkholm
@victorb
Since docs mention "You can use the bitwise OR operator to combine multiple constraints" I gave it a try to use bit-or from clojure-land, but that returns System.Int64 instead of required UnityEngine.RigidbodyConstraints
fdamirv
@fdamirv
Set it up in Unity Editor and use prefab.
Ramsey Nasser
@nasser
@victorb ClojureCLR has enum-or that does what you want in this case
try (enum-or RigidbodyConstraints/FreezePositionZ RigidbodyConstraints/FreezeRotationZ)
Victor Bjelkholm
@victorb
@fdamirv sounds like a hassle, much rather do it in code if possible :) But thanks for the suggestion
@nasser oh, that looks like it could work, thanks a lot!
fdamirv
@fdamirv

@fdamirv sounds like a hassle, much rather do it in code if possible :) But thanks for the suggestion

Yes. There was a moment I thought, that I no need prefabs any, because I use Clojure. But later I was so lazy - I just set up prefabs and instantiated gameobject.

Maybe, in my future project, I will think about it one more time.
arundilipan
@arundilipan
Hey everyone, I was experimenting with Arcadia for a Unity project, and I was wondering what the idiomatic way of instantiating a prefab to basically create projectiles/bullets in Arcadia? This is my first time really getting into Unity and so I looked around online as to how people would do it in C#, and it seems like there are instance variables attached to a MonoBehavior script that can be attached using the Unity Editor itself, but it seems like instantiate in arcadia.core only works for objects already on the scene graph? I was wondering what the best way to go about creating bullets using Arcadia would be?
Damon Kwok
@damon-kwok
But so, I found that it always happens at the beginning of the line.
Jason Chandler
@jason-chandler_gitlab

@arundilipan I can't remember if I picked this up from selfsame's tutorials or if it's in the manual:
You can actually use instantiate on any prefab like this

(instantiate (Resources/Load "sun"))

Where sun is the name of a prefab that I have in my Assets/Resources folder.
If you don't have a Resources folder in your Assets, then make one. Anything you drag into it will automatically become a prefab.

I forgot to mention: you will also need to add Resources to the :import key of your namespace
(:import [UnityEngine Debug Resources GameObject])
arundilipan
@arundilipan
thanks @jason-chandler_gitlab, I was also wondering whether if we're going to potentially have multiple instances of that prefab, whether it helps to do that instantiate or have the prefab already loaded on the scene?
Jason Chandler
@jason-chandler_gitlab

@arundilipan
Any time! Unfortunately, I don't know the answer to that question for sure. I don't think it's intensive to use Resources/Load in that way though.

I seem to remember Selfsame's youtube video using it to make very artsy staircases and the like while in-game and it didn't seem to slow down at all.

Since prefabs are prefabricated after all, it should be alright to not have them in the scene graph as far as I know. Someone please correct me and @ all involved if I am mistaken.
fdamirv
@fdamirv
This is not possible to have multiple instances (meaning C# objects) of a prefab. But you can have multiple GameObjects, that is instantiated from one prefab. Every time you call (Resources/Load "prefabName.prefab") you will get the same C# object. This is how Unity3D optimizes resource loading.
Jason Chandler
@jason-chandler_gitlab
Ah I see. I misunderstood. Thanks!
fdamirv
@fdamirv
You can't store a prefab in Scene-graph. There may be only GameObjects.
Jason Chandler
@jason-chandler_gitlab
Ah, so having a GameObject that is instantiated from a prefab in the scene from the start does not really save any resources then.
fdamirv
@fdamirv
GameObject may be (or not be) an instance of some (only one) prefab. GameObject in Scene-graph references to prefab.
*refers
arundilipan
@arundilipan

Does state+ add state in-place to a GameObject or does it return an immutable representation of a GameObject? I wanted to do something like

(-> fireball
      (state+ :physics {:speed 10})
      (state+ :traits {:damage 10 :effect :burn}))

but I'm not sure whether that would work?

Never mind, it doesn't look like it
Saikyun
@Saikyun
You have update-state as well, where you can use
Saikyun
@Saikyun
-> and assoc :)
Saikyun
@Saikyun
I think you could use doto and state+ as well. :)
fdamirv
@fdamirv

Does state+ add state in-place to a GameObject or does it return an immutable representation of a GameObject? I wanted to do something like

(-> fireball
      (state+ :physics {:speed 10})
      (state+ :traits {:damage 10 :effect :burn}))

but I'm not sure whether that would work?

state+ returns just a value you pass as a last argument.
So you cann't use it in threading macro as you want.
update-state returns new value your state stored (similar to state+).

In your case:
(state+ fireball :physics {:speed 10})
will return
{:speed 10}
On the other hand
(update-state fireball :physics assoc :speed 10)
will also return
{:speed 10}
But if you later do:
(update-state go :physics assoc :angularSpeed 3.14)
then
{:speed 10, :angularSpeed 3.14}
will be returned.

So update-state does not fit to -> threading-macro.

But you can use another threading macro - doto:

(doto go
      (arc/state+ :physics {:speed 10})
      (arc/state+ :traits {:damage 10 :effect :burn}))
fdamirv
@fdamirv
Pay attention: doto will return go.
Saikyun
@Saikyun
I meant one could put threading inside of the update-state call :)
fdamirv
@fdamirv

I think you could use doto and state+ as well. :)

Sorry, i didn't see that. @saikyun already proposed doto

Le-Brut
@Le-Brut
@nasser thanks for the response on the time estimates! Very nice to see your progress on MAGIC.
Guys, am I getting the right vibe from the Arcadia's wiki that miracle is the only repl for emacs capable of the basic features such as completion and jump-to-definition? Also, do any of the repls support syntax checking?
I am also getting a warning that the expected Unity version is 2018 (I am using 2019.3). Any known bugs/incompatibilities for U2019?
@Saikyun Hi! I am trying to set up miracle and ran into a bit of trouble, how do I satisfy the clojure-complete dependency? I tried putting the repo in Assets as clojure_complete, did AOT compile but I am getting this error: https://pastebin.com/0KZP4CkR BTW Thanks for the tutorials, they were a good place to start!
Saikyun
@Saikyun
@Le-Brut hey, thanks for the kind words ^_^ I'm sorry about that awkward dependency, I believe you need to get this specific version: https://github.com/sogaiu/clojure-complete/tree/clr-support
you can clone the repo then check out the branch clr-support
in the assets-directory as you said :)
if you have a folder in the Assets dir and the folder has a project.clj, arcadia will find it :)
I updated the docs here https://github.com/Saikyun/miracle/blob/master/README.md#installation
if you have time @Le-Brut , feel free to test them. sadly can't since I'm at work, but I think I did it right :)
Saikyun
@Saikyun
wrt: 2019 -- I think it has worked well for me last time I tried :) was 2-3 months ago so might not have been 2019.3. I think you'll be fine
I think there has been work done for better cider support with arcadia, but I haven't been involved in that. if you search this channel you might be able to find more information :)
also @sogaiu do you know if clj kondo works with clojure clr? I seem to recall you mentioning it some time
as a response to @Le-Brut thoughts on syntax checking
sogaiu
@sogaiu

@Saikyun i haven't tested clj-kondo with clojure clr, but because of this: https://github.com/clojure/clojure-clr/wiki/Specifying-types

i doubt it works out-of-the-box.

iiuc, clj-kondo uses a forked rewrite-clj and that uses tools.reader, so i would guess at the very least using a clojure-clr-aware tools.reader replacement might be necessary.

also, there are things specific to handling :clj and :cljs in the clj-kondo code base and i don't think there is any mention of :cljr in the source, so that would be another thing that is likely to need some attention.

sogaiu
@sogaiu
regarding tooling i think it could be that the chlorine plugin for atom might work. i think we may have had it working at one point: https://github.com/mauricioszabo/atom-chlorine
the author has been pretty responsive on slack in the #chlorine channel fwiw
Le-Brut
@Le-Brut
@Saikyun Thanks for updating the instruction! This time I get an error on company-complete https://pastebin.com/zvBcMUwG
Should I expect to see that library compiled in Arcadia/Compiled? (cause it's not there after AOT Compile.)
It could be that I am using the latest version of company which introduced some incompatibility, but I get a feeling that it's rather because my clj files simply aren't getting loaded by Arcadia. I have a file Assets/tryload.clj where I define a namespace https://pastebin.com/6VLkR4tY, then restart unity, start player, do (in-ns :game.test-autoload) in the repl and get this error https://pastebin.com/8w8YgMGr
I then tried adding Assets/configuration.edn with: {:source-paths ["Assets/src"]} and Assets/src directory with some clj files (and a project.clj) defining their own namespaces, adding some (LOG "test") calls, hook+ on a camera, but none of those seem to have any effect. Since plain eval-defun works, I am pretty sure at this point that none of the files are simply getting loaded.