Scripts / Keyboard select to control entities

Author
Message
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 26th Oct 2020 17:35
Lets say i have six or more entities with scrips on them ( same script or different scripts ) and i places them on the screen lets say in tree rows.
how can i move with my up and down , left and right keys between them and then select them to control them . ?
Is it possible and how would one go about to do this.

Any help is much appreciated.


Pcs
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 26th Oct 2020 23:33
Are you looking for something like this?



First of all, you have to have into account arrow keys are used for the player to walk (Well, I use them rather than WASD).
I'm using here just the "Z" key
Here I'm using a rectangle mesh as a selector tool. this rectangle runs a selector entity script.
Then, the doors run and activate entities script, activate entities include a global var, when this global var is true then the entity activates itself and runs its script, in my case, animate doors.

Still, I have to write code to get the selector going back (3-2-1 rather than like now 1-2-3), but you get the point.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 27th Oct 2020 17:36 Edited at: 27th Oct 2020 17:39
@3com, thank you for the reply.
Yes i want to do something similar. but something like in the pic below.

So lets say i have these rows of blocks and i want to rotate them clock or anti clock wise with my left and right keys ( each one individually ) . But to do that i need to be able to scroll thru them with my up and down and left and right keys and then somehow be able to select the block were my curser is , so that i then can rotate the block with my left and right keys.
That is basically what i want to do, but have no clue how to do that.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Oct 2020 19:50
"scroll thru them with my up and down and left and right keys and then somehow be able to select the block were my curser is "
First of all, does this invoke the MOUSE CURSOR?
or-- are you talking about the keys only are behaving as your selection cursor?

A> scroll through // ie select each one with keys...
B> select the block were my cursor is "...
If with just keys moving from block to block, which isn't really a difficult task.
If including the MOUSE cursor, probably requires a raycast @ tricky angles.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Oct 2020 21:24 Edited at: 27th Oct 2020 21:31
turning 2D to 3D is very confusing.. look for amen's code where he moves the character with mouse clicks and you may be able to get him to help you out - there's really no easy way in GG

it would be easier to skip the cursor part and just use a hardcoded selection
i.e. *written in the browser so forgive the indentation and any errors *
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Oct 2020 21:47
@ PC
Quote: "turning 2D to 3D is very confusing."

For that reason I opt to use the rectangle selector way, it is easiest to use and to understand how it works. appling the same logic someone might add all the meshes he wants to, and with the same way they run its animation when selected, just change animation event by rotation event, and rotate your mess, left arrow (-ax) and right arrow (+ax), and so on, as smallg point to, amen has really cool scripts that involve funky maths you would need to do so.
Now I'm running it vis arrow keys (back and forth) as you want to.

The best way to do so, at least for me comes thru selecting mesh via raycasting, and the running its code when selected or via enter key, and use amen libs to ratate then as expected.

Anyway, taking into account raycast is most focused to player intersect mesh nor mesh intersecting other mesh.
Just want to say, most likely you will have to tweak it a bit, to fit your needs.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Oct 2020 22:21 Edited at: 27th Oct 2020 22:23


Attach the script to the entities, can have as many as you want.

Use E & R keys to rotate the one you are looking at.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 27th Oct 2020 22:28 Edited at: 27th Oct 2020 22:28
Quote: "First of all, does this invoke the MOUSE CURSOR?"

No. i just want to use the keys

Quote: "turning 2D to 3D is very confusing"

i want to turn a 3D world in to a sort of 2D world

Sorry for all the confusion. to be honest , my Questions around these functions, and questions on this tread https://forum.game-guru.com/thread/222264#msg2635591 is to see if one can make a Ball game were a falling ball are being manipulated by falling on to plat forms ( any kind of block or entity) that can be rotated to change the direction of the ball going down a specific path in to a hole or bucket of some kind.

There i have said it,, the idea was, i wanted to see if i can make a game like that, if it was feasible to do.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Oct 2020 22:31
Quote: "No. i just want to use the keys"

ah i was thinking it would be fixed location with a free mouse cursor.. having it be the center of the screen is easy enough - amen already provided a solution that should work
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 27th Oct 2020 22:36 Edited at: 27th Oct 2020 22:39
@smallg,, yes it would be the idea to have the camera ( player ) fixed looking at a what seems to bee a flat surface were a ball would fall down and are then being manipulated with platforms / blocks to tilt it to the right or left by rotating the entity clockwise or anti clockwise and have the player try to get it in to a specific hole or area.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 27th Oct 2020 22:54
Maybe this would explain better i found this picture on the net.

something similar to this only difference is one must be able to control the platforms . the plyer must change the angel with the keys to guide the ball down in to a hole or specific area.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Oct 2020 22:55 Edited at: 27th Oct 2020 22:59
Ooh, sounds like a nice idea.

If a physics object stands still for too long it will go into a sleep state in the physics engine, in order to wake it up you can issue a push command ...
PushObject( objectId, 0, 0, 0 )
... will do the trick just in case you hit that issue.

Another issue you may have though is that dynamic physics objects can only have a limited number of shapes, they can't have holes in them for example, so the parts of your map that have complex shapes will have to be static entities with collision shape of 1.

Either that or you would need to make them up out of multiple entities with simple collision shapes.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Oct 2020 22:58
so something like pinball but more in line with the physics of GG.. well getting the mouse position in 3D space is not easy.
unless amen can help you i would probably just hack it by putting a hidden object at the same distance as the play area and when you move the mouse around it will move the object by a set amount (this would be determined by your play testing as it will vary based on distance to the board etc) in the same direction then you can check which platform is closest to that object / ray cast to it.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 27th Oct 2020 23:26
Quote: "Ooh, sounds like a nice idea."

Yes i also thought it would be a nice idea.

I just have to figure out how everything will going to work together , going to need to go and buy a thinking cap. hahaha
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Oct 2020 23:46
@ PCS
Getting the pinball must be more complex to do, anyway you have hard work to do, to achieve it, take it as a chance to learn something new.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 28th Oct 2020 18:39
Yeah, that sounds interesting and I crafted the script yesterday-
as far as I know.
I just have a huge emergency plumbing issue, so I'll have to check back,
that and gee what's the Census Bureau trying to do to my mind?! lol
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Oct 2020 21:42


So with this one some very simple changes result in a script that is more generic, basically if the name of the entity is 'rotate' then the E&R keys will rotate it on the Y axis but if it is called anything else then E&R keys will move it left and right instead.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 29th Oct 2020 21:00
Ok i have used some entities ( concreate blocks ) and retexture them and scale them and tried to put them together to try and illustrate what i wanted to do.
I apologize this is do not look good.

Ok so in this picture i display a ball falling down to the bottom of the play field. the idea is to rotate the green collision block as like in the picture, to get the ball in to the requested hole

Reg cross ( gear ) will rotate automatic either to the left or to the right so the balls will sometime go to the left or to the right.
then the player has to direct it down wards to the buckets or what ever.

this is just an basic idea of a game witch can change as i get more inspiration. with obstacles and so on.

hope this can explain more what i had in mind.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 30th Oct 2020 19:24
Yeah, cool. Looks kinda like the idea I had to work on a
"Plinko" style game. Plus a little bit pinball but unique.

If you do just a simple Plinko game, all the physics collision is
taken care of in engine. Now player can adjust paddles also.
Got it!
PM

Login to post a reply

Server time is: 2024-12-22 01:57:59
Your offset time is: 2024-12-22 01:57:59