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年前

この投稿はクローズされています。新しい回答、コメント、投票の追加はできません。

関連するコンテンツ