#Adventures in Rectangles (need help with programming!)
1 messages · Page 2 of 1
alright lemme try that
You'll also have to set the grabability to drag (iirc)
Grabability() is a method of the player class, not a variable?
i think?
Yeah, You have to hook it
Fisobs might have something that takes care of it for you
ooh i see
yeah fisobs has grabability stuff in the properties class
oh yeah, it worked! i was able to just change it in the properties class and now the slugcat grabs with both hands
@boreal skiff am i applying the force correctly to the crate? ive got the code (self is the player)
var phys = RoomPhysics.Get(self.room);
if (phys.TryGetObject(self.grasps[0].grabbedChunk.owner, out var obj))
{
var rb2d = obj.GetComponent<Rigidbody2D>();
rb2d.AddForce(force * self.input[0].analogueDir);
}
``` this code doesn't seem to make the crate move 
Looks good to me. Try increasing the force you apply
Like multiplying it by 3 or somethin?
Yeah, or 10000
Just to make sure that there's actually something going on here. If you apply a crazy amount of force and it doesn't move, then something else is going wrong
Ah i see
Oh, wait, I see. If you aren't using a controller, analogueDir is zero
I'm also not sure this is the way you should go about calculating the force to apply. Shouldn't you calculate the direction from the grabbed point to the player's head, then apply the force there? (if the player is greater than a certain distance away, that is)
maybe? im not too sure, this is the first time ive tried making push pull dynamics
ill try that though, id just assumed that id need like the player's directional input to see if they were pushing against it or pulling it
If the player can collide with the box, you shouldn't need any custom pushing code
oh, fair point lmao
Here's the dragging logic from the vanilla game
If the player's head (base.mainBodyChunk) is more than 5 + grabbedChunk.rad pixels away, then it applies a force to both proportional to the separation between them
ooh i see, alright thx!
if its alright, could i ask one last question @boreal skiff?
Go ahead!
alright, for the grabber body chunk, when grabbing the crate i want it to then follow its position relative to the crate until the player stops grabbing it
ive got code for an offset creator that'll make and set the grabber chunk's position to the offset of the crate, but when it runs it not only keeps it relative to the position of the crate but flips it in both x and y every time it runs
(self.grasps[0].grabbedChunk.owner as Crate).grabberPos = (self.grasps[0].grabbedChunk.owner as Crate).firstChunk.pos + offset;
do you know what's causing it?
or actually, do you know of a better way to go about this?
i got a video to show whats going on, but i just realized when the square rotates the grabber chunk doesnt rotate with it, i might need to come up with something else to keep it relative to the crate lmao
I'm not sure what this code is supposed to do. Right now, it's the same as writing:```cs
grabPos = 2 * chunkPos - grabPos;
oh shoot lmao
uhh
do you know how i could make a point always stay the same distance/angle from another point?
If point is a point that you want to stay a fixed distance away from another point, anchor:
point = (point - anchor).normalized * distance + anchor;
ah i see, alright thanks!
i mightve implemented it incorrectly lmao
elongated
I'd say
hmm
nah i just add velocity to the point if they are under water
ah i see
i can jump on the cubes like platform, pretty cool
oo make like a raft lmao
does water in the game react to the bodyChunk itself or it's texture?
water is a updateable object that pushes all bodychunk in the room
hmm
if its just reacting to the bodyChunk that's weird that its acting like that then
maybe its like being caused by the added velocity?
ocean world...
maybe we could make like a river of magma you have to float across lmao
magma? does ur map have those
in the lowest region Thermal Wastes ye (and The Forge would have molten metal), but that's quite some time before we get to that lmao
grab code soon enough will be done (need to tweak it a bit, but the dragging is done as well)
oh nice
Also, ive found a crash that occurs when loading into arena, exiting to main menu, and loading in again. It seems that the fake unity scene isnt deleted when a player exits from the arena, which crashes due to trying to make another arena with the same name (I think). It's not game breaking or anything since its just arena and easily avoidable, but we'll need to prolly find what's called when the arena's closed out so we can delete the scene when the player does so
i wounder is this some kind of body chunk pushing each other thing
Arent the tails programmed with their own physics system?
can u recreate this?
mine works fine tho
Wait actually?
Uhh im out sightseeing rn (im on vacation for the week), but ill be back in like 6 - 7 hours and see if i can get a video
Hmm
Maybe it was just going back to arena menu? Not sure
thx!
is it like watching birds and stuff
Nah we're going to some mountain ranges to go do a little hiking to some vistas, and then to some popular spots around the town here
Ah wait i just watched the full video; try doing it with the same room both times
hmm, ok ill have to test that in a bit
ok now im not getting the error... im going insane 
wait no im not going insane!!!
the crash i believe is related to the grab code somehow and the scene, its like after i die and respawn in arena if i try to grab again then the game freezes 
any error logs?
Uhh
One moment ill go see if i can get one
so it seems ive got like two of them when this happens:
one relating to a reference being null when ReleaseObject is called (which i dont hook, so worried
), and the next is about a Scene with a name already existing
Hold on, why do I see async code there?
wait whats async code 
this
Generally, it's a huge no-go in Unity since it sneakily causes things to be called from different threads, crashing when you try to next interact with Unity
If you inherit from PlayerCarryableItem, you can use the Forbid method to stop the player from grabbing it for a bit. If that's not an option, you can implement a similar system yourself (set an int variable of the PhysicalObject that counts down each tick)
oooooh i see, shoot i forgot i did hook release object 
i guess it autogenerated the async though, since i just pressed tab twice when doing it, but ill try out the inheritance from PlayerCarryableItem with Forbid, thx!!
Np
Just out of curiosity, where'd you get the await Task.Delay(200); code?
I've seen people try to use it in Rain World mods after ChatGPT told them to. Or stack overflow, actually
Ah, i looked up how to make a method wait in a program with C#, and I first found Thread.Sleep (until i figured out in game that stopped everything
), then found Task.Delay from the Microsoft docs on C# when searching if i could do it for just one method
That makes sense
I dont trust that ChatGPT could ever write for rain world lmao, and stack overflow scares me just a little bit
ah dang, im sorry to hear that
@old sphinx does the object already detect slopes?
yup
Ah lemme add that to finished on the trello then lmao
Im wondering, after the object to object, player grabbing, and some framework stuff like making this a dependency you can put on any object, do you think we should release a beta version of this while we figure out the ai problem?
maybe? i dont really see the use of a bunch of random squares/rectangles
we can change the boxcollider to be any shape tho right?
I dunno maybe people might wanna test making objects with it, not sure though
errrrr, the collision slime gave me only works on rectangles, i might find a way to deal with polygons
I think(?) we could just change the unity type (i forgor what the name of the polygon collider was called)
Im assuming we could replace the code that instantiates the boxcollider and its properties with a polygoncollider and it'd work? I think? (I hope?)
I mean like a box collider collision resolve is different from a polygon
Oooh i see
Hmm
I had assumed it'd work if the code you did for the box to collide when rotated worked
We'll have to figure somethin out for that then though 
I want to know. Have you also tested circles too?
Moving circles?
I mean... we got a physics box that can be tossed and moved around. What about a circle? Or really any shape? Like a triangle?

We can probably do it with the polygon2dcollider, but we might have to implement some custom stuff for bodyChunk to object collision
Wait updated to what point?
To the platform features and makeshift crawl spaces
Uhh i dont think so? At least im pretty sure NaClO hasn't made a pull request for it yet

i finally got around to doing this, but still get that same weird error 
on one hand though just got this horrific screen shot 
your slug is doing fine
thier are just feeling a bit under the weather
i probably do a pull once i manage to make polygon stuff work as well
Ah alright, gotcha
I tried messin around with making it a polygonCollider but it was still a square? It was weird
did u give them points
Yeah like the array that draws the lines right?
i think those are vertex
Ah i thought it drew the lines using that
Well, id say slimecubed has helped us out quite a bit, but yeah having another person could be nice, especially for the ai that we gotta tackle soon enough
AI? Sounds like pain
So we've heard, apparently its like a problem no one else has been able to fully solve for super slopes and the like? (
)
ah shoot srry for ping
nah you're good
I think at this point you're just needing to make dynamic pathfinding, which yeah noone has figured out how to do with RW creatures
how hard could it be 
You know, maybe we could try using unity's ai system to make it work? 
hmm, since you already have a system in place, maybe?
For like getting a RW room as a unity scene
Yea! I think Bro said the hard part of it was moreso getting the creatures to move with their pathfinding, since they (i think) move by like grabbing terrain with their hands
most AI have perbaked path
idk about that, rw got its own system for everything
true yeah, i dunno we'll have to figure out how to make the pathfinding recognize the unity stuff somehow
Since we're using unity for the collision can't we also use Unity Joints to connect the colliders together as well?
You definitely could

Maybe you could have them avoid boxes altogether?
Check out AImap.TileAccessibleToCreature. I would hook this, then check if the cell is touching a crate. If so, return false. Otherwise, return orig
ill check it out, thx! I gotta finish up the grab code, for some reason its being very resistant to me increasing the value the slugcat pulls at
(i think it like pulls it past the slugcat which then registers as pulling the other direction which leads to like a springing motion)
once thats done though and the polygon stuff is done, i might try something silly with the unity joints and make rw crane game
Ah wait i lied we gotta make this system into something you can like plug onto an object before that rather than its own object
What's the end goal with these? Are they gonna be objects that region authors can add to their rooms?
Yep! Stuff like movable geometry, operational machines, and the like for much more possibilities with gameplay and maybe environmental puzzles (we plan to make a region or more with them as well)
I do wanna release it as a dependency thing tho so that authors can make their own custom objects with it as well
Is a lot of that stuff going to be placeable with dev tools?
Also is a custom object system going to be implemented for simplicity (json) or is this more a code framework to add in more objects with c# code?
i think all the stuff will be placeable via dev tools, and at least right now this is being built as like a framework to add in these types of objects easily (like you'd attach it to a bodyChunk of your code), but i did have the idea of making a build-your-own object thingy that you could attach together different shapes and joints to make an object, not sure how hard that would be tho
Super Mario Slugcat Maker!
@old sphinx after i get this moss water done would you want me to help you out with the object to object/polygon code?
Huh, I've been messing around with this stuff myself and it seems pretty cool
Not adding rotation with my implementation but still very cool stuff
the fact that from what I've looked around ya'll added rotation is very commendable
ya'll are using unity rigidbodies or smth?
Yup. Cactus has it recreate the level as a Unity collider, then adds a rigidbody with a square collider for each box
It's pretty neat, it uses PhysicsScene2D to sync the updates with the game
very cool stuff
My approach is just making a UpdatableAndDeletable, and using hooks into bodychunkcollision and tile detection to get some basic rectangle. It does not work for rotations at all, but it works for the purpose of being a gimmick in like one or two regions in the mod I'm working on lmao
yo no way, i didnt think this forum would get used anymore 
Ive been takin a break from it cuz of some irl stuffs but imma be hopefully gettin back to workin on it soon, but i gotta say youve made some quite cool stuff! I still havent gotten the player movement update stuff down totally, but i think(?) from the videos youve posted it looks like you cleared that as well, lookin quite cool!
I think the scariest thing is gonna be trying to implement creature support with their ai... cuz afaik itd need like a whole rewrite of their ai for it or somethin 
In theory you could have some way to update their AI maps every few frames. Though then they won't realize that the platforms move lmao. I do wish you luck on that, as it's out of the scope of my implementation lmao
I'm not even sure if I can think of a game where AI can pathfind in a way where it realizes moving platforms move
yeah, it seems like itd need some big rewrite 
maybe with having a new pathfinding system take over the old one when in a room with a moving object, but still would need a lot 
for sure
In my case I don't need it at all as there will never be creatures in the rooms where moving platforms are in my case lmao.
ah fair enough, i wanna make mine as a library for others to use to make custom object stuff so im hopin i can figure somethin out for it


