simple 2d swinging

Blitz3D Forums/Blitz3D Programming/simple 2d swinging

Nexinarus(Posted 2012) [#1]
hello. I attempted to do swinging in 3d to start with but ran into too many problems so i tried doing a swining in 2d to start with.



Its only one way for now. And you'll have to use some imagination, but i think its not to bad.

My question is, is there anyway to do something simple like this in 3d? If so... Any suggestions?

What im looking for. I have collision detection for my 3d character.
I am not worried about rope collision. It is not needed.

Last edited 2012


Kryzon(Posted 2012) [#2]
It'd be very similar in 3D; you're still translating an object along a plane.

However, this plane is not necessarily aligned with the cartesian plane of the 2D screen.
So you can swing in several directions (whichever orientation the swing plane is), not just that single orientation you get with 2D.

Take note that with the 3D engine you get access to hierarchical transformations. These take away most of the trouble in swinging objects: attach everything you want to a pivot and spin the pivot to get the swing effect.

Run this:



Nexinarus(Posted 2012) [#3]
Ok. I think i get it. But what is the "TempYaw#" used for? For what i can tell it's not needed. But this is a cool example.

Ok so in theory.. If i want my character to swing, i would need a pivot in X units in range away from the characer, and then connect the character to the pivot as a child. rather than the parent entity. Then do something that results what similar to what your code shows. (Swinging back and forth).

Well, Im gonna give it a try. See what happens. thanks alot Kryzon. I will keep you posted on how it goes.


RemiD(Posted 2012) [#4]

If i want my character to swing, i would need a pivot in X units in range away from the characer, and then connect the character to the pivot as a child.


I was not sure about if you wanted to make a kind of grapple or not but if you want to do something like that, i suggest to use linepick from the grapple origine with the help of TFormVector so that the grapple is throwed forward, and then to check if a low tris mesh set as a pickable mesh has been picked.
If yes, you can create a pivot at this position and make the grapple origine or the player child of this pivot and have a state to decide if the character is using the grapple to move or if he is falling in the air or if he is on the ground.

You can try this to throw a linepick forward the grapple :
TFormVector(0,0,10,GrappleOrigine,0)
Linepick(EntityX(GrappleOrigine,True),EntityY(GrappleOrigine,True),EntityZ(GrappleOrigine,True),TformedX(),TFormedY(),TFormedZ())
PMesh% = PickedEntity()
If(PMesh <> 0)
 PX# = PickedX()
 PY# = PickedY()
 PZ# = PickedZ()
Endif


Last edited 2012


Nexinarus(Posted 2013) [#5]
well. Ive been trying a few different things. And not getting anywhere. But thanks for the help. I am not going to give up on swinging yet. Still playing with it.

I may also just do a cheap @$$ version of swinging i dunno yet. Depends on how frustrated i get with trying to program it.

Last edited 2013


Kryzon(Posted 2013) [#6]
That's what sharing code is for :)
Don't be shy.


Nexinarus(Posted 2013) [#7]
Dont be shy.... OK. im trying to add swinging to my Jump routine.

Plz use some imagination for now. heres the code




i used 2 spheres instead of pivots so i can see 2 points. 1 point is where the rope swings from. the other point is where the player grabs it. the character only swings 2 ways for now. Eventally I want him to swing 8 ways. (Its a start)

change the radius to change the length of the rope (which dont exist yet hehe) anyway run the prog. it should work. BTW it will create some BMPs. It needs the images.

Last edited 2013


RemiD(Posted 2013) [#8]
Is it normal that the character is able to fly when trying to move around ?

It seems you have a bug somewhere. Or a hidden jetpack maybe...


Nexinarus(Posted 2013) [#9]
what do you mean?

In my prev post i mentioned that i have the 2 points shown. i just donot have the rope there.
hehe

ill put the rope in if u want right now if it helps.

but if that isnt it. What bug are you refering too? can you be more specific?

Last edited 2013


Nexinarus(Posted 2013) [#10]
well i put the rope in... I hope this helps.

If anyone can figure out a better way, go for it. I welcome the help and i do give credit where credit is due.




RemiD(Posted 2013) [#11]

What bug are you refering too? can you be more specific?


Forget about it. There is no bug, i did not understand what your level was supposed to represent, but now i think i get it.

The grapple/rope effect seems to work ok.


Nexinarus(Posted 2013) [#12]
ok


Nexinarus(Posted 2013) [#13]
i just need help figuring out a better way to do the swinging in 8 directions. thats all I need help with.


RemiD(Posted 2013) [#14]
I have not read all your code, but i find the appearance of the level a bit weird.

If i understand correctly, we see the side of the character when in reality it is seen from up to down.

If yes, what are you trying to do ? To throw the grapple/rope toward a wall or toward the ceiling ?

Then once the grapple is planted on something, how do you want it to behave ? Do you want to attract the character toward the grapple and swing at the same time ? Or what ?


Nexinarus(Posted 2013) [#15]
the appearance is wierd, Why? Can u plz explain?

well you are looking in at a 45 degree angle inward. the reason why it looks 2d is because of the cameraviewmode i used. it makes 3d objects look 2d no mater the depth. I thought it was kinda neat.

now what i want is how to figure out the different angles to swing

I got West and East (Xaxis) figured out as u can see from the example. I am sure that North and South is the same way. (Just with the Z-axis rather thatn X-axis). I need to figure out the 45 Degree angles (NE NW SE SW). I need help with that. Its just standard swinging. Not looking for collisions with roof (not yet anyway).

Its just standard swinging for now. in 8 directions. But u did give me an idea. ZipLine hehe.


RemiD(Posted 2013) [#16]
I have retried your last demo, but i don't understand why the character is able to throw a grapple against the ground and to swing with this. Or maybe it is not the ground but a wall. I find the appearance very confusing. I don't understand what is going on, sorry.


Kryzon(Posted 2013) [#17]
He's grappling to the ceiling. It's a 2.5D view, so the ceiling isn't really visible.

As you said it yourself, it can be a bit confusing; especially since it's set up at an oblique angle (bottom right picture on this array).
This is attenuated if you rotate the camera around the Y axis by 45º degrees, so things become isometric (top right pic on that array).


RemiD(Posted 2013) [#18]
Kryzon>>Indeed, with a simple change of the view i now understand what is going on :


This is cool :)
But the grapple seems to only be thrown when moving at Left or at Right (on the X axis)


Kryzon(Posted 2013) [#19]
You can also do this, like Super Mario RPG. Replace the ";player camera" block with this:
[bbcode]
;player camera
camera=CreateCamera(player1)
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraProjMode camera,2
PositionEntity camera,10,14,-10
RotateEntity camera,45,45,0
CameraZoom camera,0.5[/bbcode]


RemiD(Posted 2013) [#20]
Or with this :
;player camera
camera=CreateCamera(player1)
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraProjMode camera,1
PositionEntity camera,1,1,-1
RotateEntity camera,45,45,0
CameraZoom camera,1



Nexinarus(Posted 2013) [#21]
Yeah I thought about Isometric. I may have to use it for testing out different swinging directions. (testing that is) Then i will go from there.