Dateien

> > CS2D > Lua Scripts > [EngiN33R] Player Collision
DateiübersichtCS2D-ÜbersichtLua Scripts-Übersicht

Englisch [EngiN33R] Player Collision >

21 Kommentare2 kb, 504 Downloads

alt [EngiN33R] Player Collision

EngiN33R
Moderator Off Offline

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 >
2× editiert, zuletzt 17.07.16 13:21:49
Zugelassen von GeoB99

Download Download

2 kb, 504 Downloads

Kommentare

21 Kommentare
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

Logge dich ein!

Du musst dich einloggen, um selber Kommentare verfassen zu können!Einloggen

alt

Yates
Reviewer Off Offline

@user Pagyra: Here, I optimized the code for you:

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)
Ich mag es!

alt

Raisun
User Off Offline

Hey, that's pretty good.
Ich mag es!

alt

Pagyra
User Off Offline

It is inefficient, there is no optimization with separation space for parts. But the fact that there is nothing similar here, it is good.
Ich mag es!

alt

HPB
User Off Offline

Nice, even the collision shape is circle.
Ich mag es!

alt

rcl1
User Off Offline

Nice
Ich mag es!

alt

Avo
User Off Offline

Nice, Vroom! :3
Ich mag es!

alt

BcY
Reviewer Off Offline

Pretty useful as it's simple.
Ich mag es!

alt

Mami Tomoe
User Off Offline

Would be nice if there was a option to push the players if they block you.
Ich mag es!

alt

Rainoth
Moderator Off Offline

user Waldin hat geschrieben
collision engine



Simple yet useful. With that said, this is just a guess but wouldn't it lag with many players?
Ich mag es!

alt

SANTER
User Off Offline

nice job dude, this is awesome
Ich mag es!

alt

Marcell
Super User Off Offline

It's okay

alt

Waldin
User Off Offline

Thanks man, i was searching for a collision engine
Edit: sry for my bad english i mean, system.
Ich mag es!
1× editiert, zuletzt 17.07.16 17:37:35

alt

ArlindS
User Off Offline

Very good.5/5
Ich mag es!

alt

Masea
Super User Off Offline

Thanks.
Ich mag es!

alt

sonkii
User Off Offline

Thanks for create this script.That idea was posted by me.Its better build in the game with options.
Ich mag es!

alt

THEMUD
User Off Offline

That is a neat masterpiece! Here is my like!
Ich mag es!

alt

Mora
User Off Offline

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.
Ich mag es!

alt

DarwinFTW
User Off Offline

Space Engin33r got dem moves
Ich mag es!

alt

G3tWr3ck3d
User Off Offline

10/10 love that space engin33r
Ich mag es!

alt

GeoB99
Moderator Off Offline

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.
Ich mag es!
Zum Anfang Vorherige 1 2 Nächste Zum Anfang