How to access functions from a script on a diffrent entity in lua?

0

I'm trying to access a function on a script on a different entity in lua but I'm not sure how to do it in lumberyard. Thank you for your help.

질문됨 6년 전208회 조회
9개 답변
0
수락된 답변
답변함 6년 전
0

I cant seem to figure this out. I've been trying to find an answer to this for 3 days. My player needs to update health variable from another script attached to another object. But I'm not sure how to access the script component variables attached to another object. Any help thank you.

답변함 6년 전
0

hey @REDACTEDUSER

Could you explain the exact use that you are trying to accomplish? Is this a shooter or something of that sort? :)

답변함 6년 전
0

Im looking for the way to access the entity's script that the raycast hit.

답변함 6년 전
0

Example: the shoot function attached to the player shooting a racast and getting enamy entity that was shot then decreaseing enamy health in enamy health script attached to enamy entity.

답변함 6년 전
0

So this isn't gonna completely help you but maybe you can derive some things going on in my code. I did this to raycast from a VR controller to get entityId's of what my controller was casting at. It's derived from the instantVR sample, but can get an entityID using the reflected 'RayCastConfiguration()'

	function raycast:raycastGrab(entityTM, ValidLocationEntity, InvalidLocationEntity, RayLength, UseNavMesh, UseTerrain, controllerEntity)
if entityTM ~= nil then
local entityPos = entityTM:GetPosition()
local rayLength = RayLength
local rayDirection = entityTM.basisY
local rayPos = nil
local rayCollision = true
self:HideLocations(ValidLocationEntity, InvalidLocationEntity)
local rayCastConfiguration = RayCastConfiguration()
rayCastConfiguration.origin = entityPos
rayCastConfiguration.direction = rayDirection
rayCastConfiguration.maxDistance = rayLength
rayCastConfiguration.physicalEntityTypes = 11 -- raycast against all but living entities
local rayCastResult = PhysicsSystemRequestBus.Broadcast.RayCast(rayCastConfiguration)
if rayCastResult:HasBlockingHit() then
topRayCastResult = rayCastResult:GetBlockingHit()
Debug.Log("entityId hit: " .. tostring(topRayCastResult['entityId']))

Might not help too much but hopefully it's a start as long as your projectile doesn't have travel speed. If it does, you may have to create a separate component to attach to your projectile spawns that track collision (not sure if you can get entityId's of collided this way, have not tried).

답변함 6년 전
0

Is it possible in lumberyard?

답변함 6년 전
0

you should work with events instead of direct reference.

답변함 5년 전
0

Hi @REDACTEDUSER

if you saw my project , you can find your answers, you can use of an empty entity / position x , y , z.

example: x for health value , y for grenade count , z for raycast shoot with Get /Set Posx or Posy or Posz .

you use GetX/EmptyEntity at Player and in AreaTrigger , you use SetX/EmptyEntity.

you must had GetId EmptyEntity.

I implemented this Global Variable Trick in Script Canvas , I'm sure , it is possible also for Lua.

https://forums.awsgametech.com/t/script-canvas-tutorials-lets-get-start-lumberyard-1-14-robot-island/5282/1

답변함 6년 전

이 게시물은 마감됨: 새 답변, 댓글 및 투표 추가가 비활성화되었습니다.

관련 콘텐츠