#Adventures in Rectangles (need help with programming!)

1 messages · Page 2 of 1

boreal skiff
#

I believe it's 0

silk narwhal
#

alright lemme try that

boreal skiff
#

You'll also have to set the grabability to drag (iirc)

silk narwhal
#

grabability is a variable of the Player class right?

#

wait

silk narwhal
#

i think?

boreal skiff
#

Yeah, You have to hook it
Fisobs might have something that takes care of it for you

silk narwhal
#

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

silk narwhal
#

@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 ![hunterthinking](https://cdn.discordapp.com/emojis/695022454577299546.webp?size=128 "hunterthinking")
boreal skiff
#

Looks good to me. Try increasing the force you apply

silk narwhal
boreal skiff
#

Yeah, or 10000

silk narwhal
#

Lmao alright

boreal skiff
#

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

silk narwhal
#

Ah i see

boreal skiff
#

Oh, wait, I see. If you aren't using a controller, analogueDir is zero

silk narwhal
#

oooooh

#

yeah im on keyboard lmao

boreal skiff
#

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)

silk narwhal
#

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

boreal skiff
#

If the player can collide with the box, you shouldn't need any custom pushing code

silk narwhal
#

oh, fair point lmao

boreal skiff
#

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

silk narwhal
#

ooh i see, alright thx!

#

if its alright, could i ask one last question @boreal skiff?

boreal skiff
#

Go ahead!

silk narwhal
#

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

boreal skiff
silk narwhal
#

oh shoot lmao

#

uhh

#

do you know how i could make a point always stay the same distance/angle from another point?

boreal skiff
#

If point is a point that you want to stay a fixed distance away from another point, anchor:

point = (point - anchor).normalized * distance + anchor;
silk narwhal
#

ah i see, alright thanks!

silk narwhal
#

i mightve implemented it incorrectly lmao

stark jetty
#

Amazing a terrifying

old sphinx
#

elongated

old sphinx
#

oof

#

rw water really hates crates

#

lol

silk narwhal
#

oh that is wack lmao

#

are you simulating it with like a unity fluid simulation?

stark jetty
#

Umhhhh

#

Interesting

brazen ravine
#

I'd say

old sphinx
#

the water goes nuts

#

i donno why

silk narwhal
#

hmm

old sphinx
silk narwhal
#

ah i see

old sphinx
#

i can jump on the cubes like platform, pretty cool

silk narwhal
#

oo make like a raft lmao

#

does water in the game react to the bodyChunk itself or it's texture?

old sphinx
#

water is a updateable object that pushes all bodychunk in the room

silk narwhal
#

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?

old sphinx
#

probably

#

im just thinking about a slug cat waking up on a raft

silk narwhal
#

ocean world...

#

maybe we could make like a river of magma you have to float across lmao

old sphinx
#

magma? does ur map have those

silk narwhal
#

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

silk narwhal
old sphinx
#

oh nice

silk narwhal
#

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

old sphinx
silk narwhal
old sphinx
#

mine works fine tho

silk narwhal
#

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

old sphinx
#

i dont have issue

silk narwhal
#

Hmm

old sphinx
#

sight seeing vacation sounds cool

#

have fun

silk narwhal
#

Maybe it was just going back to arena menu? Not sure

silk narwhal
old sphinx
#

is it like watching birds and stuff

silk narwhal
#

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

silk narwhal
# old sphinx yeah

Ah wait i just watched the full video; try doing it with the same room both times

old sphinx
#

i tried that

#

nothing happen

silk narwhal
#

hmm, ok ill have to test that in a bit

silk narwhal
#

ok now im not getting the error... im going insane rivworried

silk narwhal
#

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 hunterthinking

old sphinx
#

any error logs?

silk narwhal
#

Uhh

#

One moment ill go see if i can get one

#

one relating to a reference being null when ReleaseObject is called (which i dont hook, so worried rivworried), and the next is about a Scene with a name already existing

boreal skiff
#

Hold on, why do I see async code there?

silk narwhal
boreal skiff
#

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)

silk narwhal
#

oooooh i see, shoot i forgot i did hook release object hunterkek
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!!

boreal skiff
#

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

silk narwhal
boreal skiff
#

That makes sense

silk narwhal
#

I dont trust that ChatGPT could ever write for rain world lmao, and stack overflow scares me just a little bit

old sphinx
#

i wish i can use chagpt

#

my place doesnt allow that

silk narwhal
#

ah dang, im sorry to hear that

silk narwhal
#

@old sphinx does the object already detect slopes?

old sphinx
#

yup

silk narwhal
#

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?

old sphinx
#

maybe? i dont really see the use of a bunch of random squares/rectangles

silk narwhal
#

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

old sphinx
#

errrrr, the collision slime gave me only works on rectangles, i might find a way to deal with polygons

silk narwhal
#

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?)

old sphinx
#

Yeah, but bodychunk to collider collision

#

Isn’t automatic

silk narwhal
#

Wait wdym

#

like the slugcat standing on it would break?

old sphinx
#

I mean like a box collider collision resolve is different from a polygon

silk narwhal
#

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 hunterthinking

sweet crest
#

I want to know. Have you also tested circles too?

old sphinx
#

Moving circles?

sweet crest
#

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?

old sphinx
silk narwhal
stark jetty
#

The GitHub it's updated now?

silk narwhal
stark jetty
#

To the platform features and makeshift crawl spaces

silk narwhal
stark jetty
silk narwhal
silk narwhal
#

on one hand though just got this horrific screen shot fear

old sphinx
#

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

silk narwhal
#

Ah alright, gotcha

#

I tried messin around with making it a polygonCollider but it was still a square? It was weird

silk narwhal
old sphinx
#

i think those are vertex

silk narwhal
#

Ah i thought it drew the lines using that

old sphinx
#

kinda sad that only two people working on this cool project( plus cool slimecubed

silk narwhal
#

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

brazen ravine
#

AI? Sounds like pain

silk narwhal
#

ah shoot srry for ping

brazen ravine
#

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

silk narwhal
#

how hard could it be trolley

#

You know, maybe we could try using unity's ai system to make it work? saintsmirk

brazen ravine
#

hmm, since you already have a system in place, maybe?

#

For like getting a RW room as a unity scene

silk narwhal
#

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

old sphinx
#

most AI have perbaked path

old sphinx
silk narwhal
silk narwhal
#

Since we're using unity for the collision can't we also use Unity Joints to connect the colliders together as well?

boreal skiff
#

You definitely could

silk narwhal
boreal skiff
silk narwhal
#

once thats done though and the polygon stuff is done, i might try something silly with the unity joints and make rw crane game

silk narwhal
boreal skiff
#

What's the end goal with these? Are they gonna be objects that region authors can add to their rooms?

silk narwhal
silk narwhal
sweet crest
#

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?

silk narwhal
brazen ravine
#

Super Mario Slugcat Maker!

silk narwhal
#

Rain World: Tears of the Kingdom...

silk narwhal
#

@old sphinx after i get this moss water done would you want me to help you out with the object to object/polygon code?

kind egret
#

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

kind egret
#

ya'll are using unity rigidbodies or smth?

boreal skiff
#

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

kind egret
#

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

silk narwhal
#

yo no way, i didnt think this forum would get used anymore hunterkek
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 1000quotastare

kind egret
#

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

silk narwhal
kind egret
#

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.

silk narwhal
#

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

boreal skiff
#

Personally, I would just add a placed object that marks a specific area as disallowed for creatures. You can add whack a mole holes or something as an alternate path for them

#

Perhaps if an object is stationary for long enough you can recalculate the AI map to let them walk over it