C# Basic animation, cant get a circle to align between two lines
I have the following code which aims to animate two basic pistons connected to one crank but genuinely dont understand why the pistons arent on the same crank, the second animates in the correct circle motion just not onto the crank, the code is just the draw code not the full timing stuff if you want that i can add it too.
https://paste.mod.gg/capoiiuwymsk/0
i know the code is messy and some subroutines need to be introduced etc i just need to get this working before i clean it up and move into a much larger project
BlazeBin - capoiiuwymsk
A tool for sharing your source code with the world!
26 Replies
I'll be so real, I am just having a lot of trouble visualizing this from the math alone lol. Am happy to try to help, but can you toss this up on GitHub (or some other repo -- or just a zip of the whole project) so I can open the project and run the code, so I can see how changing different parts affects things?
yes sure
one sec lol
Any uploads i am trying keep failing have you got any websites you would recommend file is pretty big
@JP
I generally drop things on google drive
or use github for code
its too big lol, i might have a previous version of the project missing some bits but this but should still work
let me try that
you can open a terminal and run
on windows if you don't have it already
then
git init
inside your project's folder to create a git repository there
then you can either use your IDE's git tooling to commit files, if you're using one (like VSCode)
or a git add *
followed by git commit -m "initial commit"
to commit everythinghttps://drive.google.com/drive/folders/1Hvo3el73h4d2xas-CURYmJF8zdl4F8vF?usp=sharing
i was avoiding this as its linked to a college account with weird restrictions
basically launch the project click load engine save click one of the txt files and jost proceed through it all
this is an old hacked apart version so it would actually upload over my slow wifi so is a bit weird
mfw the MS Forms libs only work on Windows 😢
give me a bit, need to start up a windows box
nw
u on cool ppl linux
?
I do be lol
you got it running all good?
no, not at all, I've left the windows pc to install dotnet sdk and such, am just reading through the code on my main computer now until that's done
okay sounds cool if u need any sorta explanations ill be on stack overflow 🤣
sounds good lol
Ok, I think the fundamental point of confusion is that there is some transform that is applied to your "crank shaft" that makes it not actually at the center
the first piston was designed with the same transform, I think, so it just works
but the second piston was rotated using a different transform, which throws everything off
you can demo this for yourself by moving these transform lines
that yields a layout like this, where the crank shaft is at the center of the two, but neither are aligned
ah so because my 'crank' isnt the centre of the scene the transforms mean that its always off centre andbeing moved too?
I think those transforms make it so it is not truly centered, yes
and since the its being moved with the first transform it matches the first but not the second
i genuinely cant thank you enough i have been trying to fix this for like a couple hours
Hah! happy to help lol
This is one of those things where you look at the same code so much you become blind to it lol
im going to test it without the centre being off centre and let you know what it does, but once again thanks so much
its such ugly code too i have no idea how you managed
I have a lot of experience writing ugly code 😉
yeah, happy to brainstorm if it ends up not straightforward to fix! lmk how it goes!
will do might not be tonight though how long do threads stay open as i have work tommorow morning 🙄
Not sure tbh, you can just ping me in one of the channels if this ends up auto-closed
alright thanks again for your help :thumbsupsmiley:
gotchu!
hiya man thought id let you know i managed to get it to work perfectly by changing the transforsm to include the fly wheels y coordinate offset and its all working now 🎊
like this:
Hey, awesome 🎉
thanks for lettin me know!