English [EngiN33R] Player Collision icon

21 comments
17.07.16 11:23:17 am
like 20 like it!
2 kb, 496 Downloads
EngiN33R
Moderator
Offline Off
This is an extremely simple and short script that makes players unable to pass through each other. It was also designed as an educational tool to demonstrate some of the mathematics commonly used in CS2D scripts. The entire script is 16 lines long and provided in the description below because of its small size. Be aware that this collision mechanism may be slightly confusing and may not work ideally for players with a high latency.

I welcome any and all questions regarding how it works, and any improvements to it as well - bear in mind, however, that this is not the end-all solution, but a simple script that enables basic collision functionality.

Code >
image
edited 2×, last 17.07.16 01:21:49 pm
ok This file has been reviewed and approved by GeoB99 (17.07.16 11:25:05 am)

Comments

21 comments
Goto Page
To the start Previous 1 2 Next To the start

Log in!

You need to log in to be able to write comments!Log in
19.07.16 07:13:09 pm
like I like it!
Up
Yates
Reviewer
Offline Off
@user Pagyra: Here, I optimized the code for you:

Code:
1
addhook("move", "collisionThink") function collisionThink(ply, x, y) for _, ply2 in pairs(player(0, "table")) do if (ply ~= ply2 and player(ply2, "health") > 0) then local x2, y2 = player(ply2, "x"), player(ply2, "y"); local d = math.sqrt((x2-x)^2 + (y2-y)^2); if (d < 30) then local a = -(math.atan2(x2-x,y2-y)+math.pi/2)%(2*math.pi); local nx, ny = x2 + math.cos(a)*30, y2 + math.sin(a)*30; if (tile(math.floor(nx/32), math.floor(ny/32), "walkable")) then parse("setpos " .. ply .. " " .. nx .. " " .. ny); end end end end end


I even added semi-colons so Lua can read it
0.000000000000000000000000000000000000000000000002
seconds faster! (actual 100% legit full proof speed test)
19.07.16 04:43:38 pm
like I like it!
Up
Raisun
User
Offline Off
Hey, that's pretty good.
19.07.16 10:36:47 am
like I like it!
Up
Pagyra
User
Offline Off
It is inefficient, there is no optimization with separation space for parts. But the fact that there is nothing similar here, it is good.
19.07.16 09:29:11 am
like I like it!
Up
HPB
User
Offline Off
Nice, even the collision shape is circle.
18.07.16 07:41:35 pm
like I like it!
Up
rcl1
User
Offline Off
Nice
17.07.16 08:06:55 pm
like I like it!
Up
Avo
User
Offline Off
Nice, Vroom! :3
17.07.16 07:23:03 pm
like I like it!
Up
BcY
Reviewer
Offline Off
Pretty useful as it's simple.
17.07.16 05:34:44 pm
like I like it!
Up
Mami Tomoe
User
Offline Off
Would be nice if there was a option to push the players if they block you.
17.07.16 05:31:23 pm
like I like it!
Up
Rainoth
Moderator
Offline Off
user Waldin has written:
collision engine



Simple yet useful. With that said, this is just a guess but wouldn't it lag with many players?
17.07.16 05:16:17 pm
like I like it!
Up
SANTER
User
Offline Off
nice job dude, this is awesome
17.07.16 05:11:20 pm
Up
Marcell
Super User
Offline Off
It's okay
17.07.16 05:07:31 pm
like I like it!
Up
Waldin
User
Offline Off
Thanks man, i was searching for a collision engine
Edit: sry for my bad english i mean, system.
edited 1×, last 17.07.16 05:37:35 pm
17.07.16 04:36:56 pm
like I like it!
Up
ArlindS
User
Offline Off
Very good.5/5
17.07.16 02:55:13 pm
like I like it!
Up
Masea
Super User
Offline Off
Thanks.
17.07.16 02:49:17 pm
like I like it!
Up
sonkii
User
Offline Off
Thanks for create this script.That idea was posted by me.Its better build in the game with options.
17.07.16 01:02:13 pm
like I like it!
Up
THEMUD
User
Offline Off
That is a neat masterpiece! Here is my like!
17.07.16 12:28:09 pm
like I like it!
Up
Mora
User
Offline Off
Omg when i moving on a players is looks very nice.. When you holding "D" key and automatically going up or down. Like there is really a human, these feelings.
17.07.16 12:03:40 pm
like I like it!
Up
DarwinFTW
User
Offline Off
Space Engin33r got dem moves
17.07.16 11:52:05 am
like I like it!
Up
G3tWr3ck3d
User
Offline Off
10/10 love that space engin33r
17.07.16 11:36:45 am
like I like it!
Up
GeoB99
Moderator
Offline Off
In my humble opinion, this feature should come by default amongst with a global server command sv_plcollision to enable / disable the solid state collision between players.

Otherwise, may can you implement this as a small improvement? Would be appreciated.
To the start Previous 1 2 Next To the start